2014-03-25 21:13:55 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-02-27 02:44:00 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Dlna.PlayTo
|
|
|
|
|
{
|
|
|
|
|
class StreamHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the audio URL.
|
|
|
|
|
/// </summary>
|
2014-03-23 05:10:33 +00:00
|
|
|
|
/// <param name="deviceProperties">The device properties.</param>
|
2014-02-27 02:44:00 +00:00
|
|
|
|
/// <param name="item">The item.</param>
|
2014-03-23 05:10:33 +00:00
|
|
|
|
/// <param name="streams">The streams.</param>
|
2014-02-27 02:44:00 +00:00
|
|
|
|
/// <param name="serverAddress">The server address.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
2014-03-23 05:10:33 +00:00
|
|
|
|
internal static string GetAudioUrl(DeviceInfo deviceProperties, PlaylistItem item, List<MediaStream> streams, string serverAddress)
|
2014-02-27 02:44:00 +00:00
|
|
|
|
{
|
2014-03-24 17:54:45 +00:00
|
|
|
|
var dlnaCommand = BuildDlnaUrl(deviceProperties, item);
|
2014-02-27 02:44:00 +00:00
|
|
|
|
|
2014-03-23 05:10:33 +00:00
|
|
|
|
return string.Format("{0}/audio/{1}/stream{2}?{3}", serverAddress, item.ItemId, "." + item.Container.TrimStart('.'), dlnaCommand);
|
2014-02-27 02:44:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the video URL.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="deviceProperties">The device properties.</param>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="streams">The streams.</param>
|
|
|
|
|
/// <param name="serverAddress">The server address.</param>
|
|
|
|
|
/// <returns>The url to send to the device</returns>
|
2014-03-13 19:08:02 +00:00
|
|
|
|
internal static string GetVideoUrl(DeviceInfo deviceProperties, PlaylistItem item, List<MediaStream> streams, string serverAddress)
|
2014-02-27 02:44:00 +00:00
|
|
|
|
{
|
2014-03-24 17:54:45 +00:00
|
|
|
|
var dlnaCommand = BuildDlnaUrl(deviceProperties, item);
|
2014-02-27 02:44:00 +00:00
|
|
|
|
|
2014-03-22 19:37:15 +00:00
|
|
|
|
return string.Format("{0}/Videos/{1}/stream{2}?{3}", serverAddress, item.ItemId, item.Container, dlnaCommand);
|
2014-02-27 02:44:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the dlna URL.
|
|
|
|
|
/// </summary>
|
2014-03-24 17:54:45 +00:00
|
|
|
|
private static string BuildDlnaUrl(DeviceInfo deviceProperties, PlaylistItem item)
|
2014-02-27 02:44:00 +00:00
|
|
|
|
{
|
2014-03-23 05:10:33 +00:00
|
|
|
|
var usCulture = new CultureInfo("en-US");
|
2014-03-24 17:54:45 +00:00
|
|
|
|
|
2014-03-23 05:10:33 +00:00
|
|
|
|
var list = new List<string>
|
|
|
|
|
{
|
2014-03-24 17:54:45 +00:00
|
|
|
|
deviceProperties.UUID ?? string.Empty,
|
|
|
|
|
item.MediaSourceId ?? string.Empty,
|
|
|
|
|
(!item.Transcode).ToString().ToLower(),
|
|
|
|
|
item.VideoCodec ?? string.Empty,
|
|
|
|
|
item.AudioCodec ?? string.Empty,
|
|
|
|
|
item.AudioStreamIndex.HasValue ? item.AudioStreamIndex.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.SubtitleStreamIndex.HasValue ? item.SubtitleStreamIndex.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.VideoBitrate.HasValue ? item.VideoBitrate.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.AudioBitrate.HasValue ? item.AudioBitrate.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.MaxAudioChannels.HasValue ? item.MaxAudioChannels.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.MaxFramerate.HasValue ? item.MaxFramerate.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.MaxWidth.HasValue ? item.MaxWidth.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.MaxHeight.HasValue ? item.MaxHeight.Value.ToString(usCulture) : string.Empty,
|
|
|
|
|
item.StartPositionTicks.ToString(usCulture),
|
|
|
|
|
item.VideoLevel.HasValue ? item.VideoLevel.Value.ToString(usCulture) : string.Empty
|
2014-03-23 05:10:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return string.Format("Params={0}", string.Join(";", list.ToArray()));
|
2014-02-27 02:44:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-14 14:27:32 +00:00
|
|
|
|
}
|