one more standardization of contentFeatures

pull/702/head
Luke Pulverenti 11 years ago
parent 44bfad70d2
commit 62bf617278

@ -297,7 +297,7 @@ namespace MediaBrowser.Dlna.Server
} }
else else
{ {
Browse_AddItem(result, i, user, deviceId, filter); Browse_AddItem(result, i, deviceId, filter);
} }
} }
} }
@ -372,7 +372,7 @@ namespace MediaBrowser.Dlna.Server
} }
else else
{ {
Browse_AddItem(result, i, user, deviceId, filter); Browse_AddItem(result, i, deviceId, filter);
} }
} }
@ -515,7 +515,7 @@ namespace MediaBrowser.Dlna.Server
} }
} }
private void Browse_AddItem(XmlDocument result, BaseItem item, User user, string deviceId, Filter filter) private void Browse_AddItem(XmlDocument result, BaseItem item, string deviceId, Filter filter)
{ {
var element = result.CreateElement(string.Empty, "item", NS_DIDL); var element = result.CreateElement(string.Empty, "item", NS_DIDL);
element.SetAttribute("restricted", "1"); element.SetAttribute("restricted", "1");
@ -590,22 +590,12 @@ namespace MediaBrowser.Dlna.Server
} }
} }
var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video && !string.Equals(i.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)); var totalBitrate = streamInfo.TotalOutputBitrate;
var targetAudioBitrate = streamInfo.TargetAudioBitrate;
var targetSampleRate = streamInfo.TargetAudioSampleRate; var targetSampleRate = streamInfo.TargetAudioSampleRate;
var targetChannels = streamInfo.TargetAudioChannels; var targetChannels = streamInfo.TargetAudioChannels;
var targetWidth = streamInfo.MaxWidth ?? (videoStream == null ? null : videoStream.Width); var targetWidth = streamInfo.TargetWidth;
var targetHeight = streamInfo.MaxHeight ?? (videoStream == null ? null : videoStream.Height); var targetHeight = streamInfo.TargetHeight;
var targetVideoCodec = streamInfo.IsDirectStream
? (videoStream == null ? null : videoStream.Codec)
: streamInfo.VideoCodec;
var targetAudioCodec = streamInfo.TargetAudioCodec;
var targetBitrate = maxBitrateSetting ?? mediaSource.Bitrate;
if (targetChannels.HasValue) if (targetChannels.HasValue)
{ {
@ -625,48 +615,36 @@ namespace MediaBrowser.Dlna.Server
res.SetAttribute("sampleFrequency", targetSampleRate.Value.ToString(_usCulture)); res.SetAttribute("sampleFrequency", targetSampleRate.Value.ToString(_usCulture));
} }
if (targetAudioBitrate.HasValue) if (totalBitrate.HasValue)
{ {
res.SetAttribute("bitrate", targetAudioBitrate.Value.ToString(_usCulture)); res.SetAttribute("bitrate", totalBitrate.Value.ToString(_usCulture));
} }
var mediaProfile = _profile.GetVideoMediaProfile(streamInfo.Container, var mediaProfile = _profile.GetVideoMediaProfile(streamInfo.Container,
streamInfo.AudioCodec, streamInfo.AudioCodec,
streamInfo.VideoCodec); streamInfo.VideoCodec);
var formatProfile = mediaProfile == null ? null : mediaProfile.OrgPn;
if (string.IsNullOrEmpty(formatProfile))
{
var format = new MediaFormatProfileResolver().ResolveVideoFormat(streamInfo.Container,
targetVideoCodec,
targetAudioCodec,
targetWidth,
targetHeight,
targetBitrate,
streamInfo.TargetTimestamp);
formatProfile = format.HasValue ? format.Value.ToString() : null;
}
var filename = url.Substring(0, url.IndexOf('?')); var filename = url.Substring(0, url.IndexOf('?'));
var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType) var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename) ? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType; : mediaProfile.MimeType;
var orgOpValue = DlnaMaps.GetOrgOpValue(mediaSource.RunTimeTicks.HasValue, streamInfo.IsDirectStream, streamInfo.TranscodeSeekInfo); var contentFeatures = new ContentFeatureBuilder(_profile).BuildVideoHeader(streamInfo.Container,
streamInfo.VideoCodec,
var orgCi = streamInfo.IsDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; streamInfo.AudioCodec,
var orgPn = !string.IsNullOrEmpty(formatProfile) ? "DLNA.ORG_PN=:" + formatProfile + ";" : string.Empty; targetWidth,
targetHeight,
totalBitrate,
streamInfo.TargetTimestamp,
streamInfo.IsDirectStream,
streamInfo.RunTimeTicks,
streamInfo.TranscodeSeekInfo);
res.SetAttribute("protocolInfo", String.Format( res.SetAttribute("protocolInfo", String.Format(
"http-get:*:{0}:{1}DLNA.ORG_OP={2};DLNA.ORG_CI={3};DLNA.ORG_FLAGS={4}", "http-get:*:{0}:{1}",
mimeType, mimeType,
orgPn, contentFeatures
orgOpValue,
orgCi,
DlnaMaps.DefaultStreaming
)); ));
container.AppendChild(res); container.AppendChild(res);
@ -731,35 +709,25 @@ namespace MediaBrowser.Dlna.Server
var mediaProfile = _profile.GetAudioMediaProfile(streamInfo.Container, var mediaProfile = _profile.GetAudioMediaProfile(streamInfo.Container,
streamInfo.AudioCodec); streamInfo.AudioCodec);
var formatProfile = mediaProfile == null ? null : mediaProfile.OrgPn;
if (string.IsNullOrEmpty(formatProfile))
{
var format = new MediaFormatProfileResolver().ResolveAudioFormat(streamInfo.Container,
targetAudioBitrate, targetSampleRate, targetChannels);
formatProfile = format.HasValue ? format.Value.ToString() : null;
}
var filename = url.Substring(0, url.IndexOf('?')); var filename = url.Substring(0, url.IndexOf('?'));
var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType) var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename) ? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType; : mediaProfile.MimeType;
var orgOpValue = DlnaMaps.GetOrgOpValue(mediaSource.RunTimeTicks.HasValue, streamInfo.IsDirectStream, streamInfo.TranscodeSeekInfo); var contentFeatures = new ContentFeatureBuilder(_profile).BuildAudioHeader(streamInfo.Container,
streamInfo.TargetAudioCodec,
var orgCi = streamInfo.IsDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; targetAudioBitrate,
targetSampleRate,
var orgPn = !string.IsNullOrEmpty(formatProfile) ? "DLNA.ORG_PN=:" + formatProfile + ";" : string.Empty; targetChannels,
streamInfo.IsDirectStream,
streamInfo.RunTimeTicks,
streamInfo.TranscodeSeekInfo);
res.SetAttribute("protocolInfo", String.Format( res.SetAttribute("protocolInfo", String.Format(
"http-get:*:{0}:{1}DLNA.ORG_OP={2};DLNA.ORG_CI={3};DLNA.ORG_FLAGS={4}", "http-get:*:{0}:{1}",
mimeType, mimeType,
orgPn, contentFeatures
orgOpValue,
orgCi,
DlnaMaps.DefaultStreaming
)); ));
container.AppendChild(res); container.AppendChild(res);

Loading…
Cancel
Save