Added MimeType to PlayTo profile

This commit is contained in:
7illusions 2014-03-12 21:01:19 +01:00
parent 5fcfe3bda5
commit 438b0078cc
5 changed files with 49 additions and 11 deletions

View File

@ -53,7 +53,7 @@
</Compile>
<Compile Include="PlayTo\Argument.cs" />
<Compile Include="PlayTo\Configuration\DlnaProfile.cs" />
<Compile Include="PlayTo\Configuration\PluginConfiguration.cs" />
<Compile Include="PlayTo\Configuration\PlayToConfiguration.cs" />
<Compile Include="PlayTo\Configuration\TranscodeSetting.cs" />
<Compile Include="PlayTo\CurrentIdEventArgs.cs" />
<Compile Include="PlayTo\Device.cs">

View File

@ -29,7 +29,12 @@
FriendlyName = "^TV$",
ModelNumber = @"1\.0",
ModelName = "Samsung DTV DMR",
TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings()
TranscodeSettings = new[]
{
new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"},
new TranscodeSettings {Container = "flac", TargetContainer = "mp3"},
new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"}
}
};
var profile1 = new DlnaProfile
@ -38,7 +43,12 @@
ClientType = "DLNA",
FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung",
ModelNumber = @"(1\.0)|(AllShare1\.0)",
TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings()
TranscodeSettings = new[]
{
new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"},
new TranscodeSettings {Container = "flac", TargetContainer = "mp3"},
new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"}
}
};
var profile2 = new DlnaProfile
@ -47,7 +57,12 @@
ClientType = "DLNA",
FriendlyName = @"(^TV-\d{2}C\d{3}.*)|(^\[TV\][A-Z]{2}\d{2}(D)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung",
ModelNumber = @"(1\.0)|(AllShare1\.0)",
TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings()
TranscodeSettings = new[]
{
new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"},
new TranscodeSettings {Container = "flac", TargetContainer = "mp3"},
new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"}
}
};
var profile3 = new DlnaProfile

View File

@ -21,6 +21,12 @@ namespace MediaBrowser.Dlna.PlayTo.Configuration
/// </value>
public string TargetContainer { get; set; }
/// <summary>
/// Gets or sets the Mimetype to enforce
/// </summary>
/// <value>
/// The MimeType.
/// </value>
public string MimeType { get; set; }
/// <summary>

View File

@ -16,6 +16,8 @@ namespace MediaBrowser.Dlna.PlayTo
public string FileFormat { get; set; }
public string MimeType { get; set; }
public int PlayState { get; set; }
public string StreamUrl { get; set; }
@ -51,10 +53,21 @@ namespace MediaBrowser.Dlna.PlayTo
{
if (string.IsNullOrWhiteSpace(transcodeSetting.Container))
continue;
if (path.EndsWith(transcodeSetting.Container))
if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.TargetContainer))
{
playlistItem.Transcode = true;
playlistItem.FileFormat = transcodeSetting.TargetContainer;
if (string.IsNullOrWhiteSpace(transcodeSetting.MimeType))
playlistItem.MimeType = transcodeSetting.MimeType;
return playlistItem;
}
if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.MimeType))
{
playlistItem.Transcode = false;
playlistItem.FileFormat = transcodeSetting.Container;
playlistItem.MimeType = transcodeSetting.MimeType;
return playlistItem;
}
}

View File

@ -96,9 +96,12 @@ namespace MediaBrowser.Dlna.PlayTo
/// <returns>The url to send to the device</returns>
internal static string GetVideoUrl(DeviceProperties deviceProperties, PlaylistItem item, List<MediaStream> streams, string serverAddress)
{
string dlnaCommand = string.Empty;
if (!item.Transcode)
return string.Format("{0}/Videos/{1}/stream.{2}?Static=True", serverAddress, item.ItemId, item.FileFormat);
{
dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, !item.Transcode, null, null, null, null, null, null, null, null, null, null, item.MimeType);
return string.Format("{0}/Videos/{1}/stream.{2}?{3}", serverAddress, item.ItemId, item.FileFormat, dlnaCommand);
}
var videostream = streams.Where(m => m.Type == MediaStreamType.Video).OrderBy(m => m.IsDefault).FirstOrDefault();
var audiostream = streams.Where(m => m.Type == MediaStreamType.Audio).OrderBy(m => m.IsDefault).FirstOrDefault();
@ -117,7 +120,7 @@ namespace MediaBrowser.Dlna.PlayTo
audioChannels = 2;
}
string dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, videoCodec, audioCodec, null, null, videoBitrate, audioChannels, audioBitrate, item.StartPositionTicks, "baseline", "3");
dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, !item.Transcode, videoCodec, audioCodec, null, null, videoBitrate, audioChannels, audioBitrate, item.StartPositionTicks, "baseline", "3", item.MimeType);
return string.Format("{0}/Videos/{1}/stream.{2}?{3}", serverAddress, item.ItemId, item.FileFormat, dlnaCommand);
}
@ -162,12 +165,12 @@ namespace MediaBrowser.Dlna.PlayTo
/// <summary>
/// Builds the dlna URL.
/// </summary>
private static string BuildDlnaUrl(string deviceID, VideoCodecs? videoCodec, AudioCodecs? audioCodec, int? subtitleIndex, int? audiostreamIndex, int? videoBitrate, int? audiochannels, int? audioBitrate, long? startPositionTicks, string profile, string videoLevel)
private static string BuildDlnaUrl(string deviceID, bool isStatic, VideoCodecs? videoCodec, AudioCodecs? audioCodec, int? subtitleIndex, int? audiostreamIndex, int? videoBitrate, int? audiochannels, int? audioBitrate, long? startPositionTicks, string profile, string videoLevel, string mimeType)
{
var usCulture = new CultureInfo("en-US");
var dlnaparam = string.Format("Params={0};", deviceID);
dlnaparam += isStatic ? "true;" : "false;";
dlnaparam += videoCodec.HasValue ? videoCodec.Value + ";" : ";";
dlnaparam += audioCodec.HasValue ? audioCodec.Value + ";" : ";";
dlnaparam += audiostreamIndex.HasValue ? audiostreamIndex.Value.ToString(usCulture) + ";" : ";";
@ -178,6 +181,7 @@ namespace MediaBrowser.Dlna.PlayTo
dlnaparam += startPositionTicks.HasValue ? startPositionTicks.Value.ToString(usCulture) + ";" : ";";
dlnaparam += profile + ";";
dlnaparam += videoLevel + ";";
dlnaparam += mimeType + ";";
return dlnaparam;
}