Skip to content

Commit

Permalink
Merge pull request #2372 from MediaBrowser/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
LukePulverenti authored Dec 28, 2016
2 parents 02cbad1 + 57c34d8 commit 7dbdb75
Show file tree
Hide file tree
Showing 245 changed files with 3,829 additions and 2,268 deletions.
24 changes: 21 additions & 3 deletions BDInfo/BDROM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public delegate bool OnPlaylistFileScanError(
public BDROM(
string path, IFileSystem fileSystem, ITextEncoding textEncoding)
{
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentNullException("path");
}

_fileSystem = fileSystem;
//
// Locate BDMV directories.
Expand Down Expand Up @@ -326,15 +331,28 @@ public void Scan()
private FileSystemMetadata GetDirectoryBDMV(
string path)
{
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentNullException("path");
}

FileSystemMetadata dir = _fileSystem.GetDirectoryInfo(path);

while (dir != null)
{
if (dir.Name == "BDMV")
if (string.Equals(dir.Name, "BDMV", StringComparison.OrdinalIgnoreCase))
{
return dir;
}
dir = _fileSystem.GetDirectoryInfo(Path.GetDirectoryName(dir.FullName));
var parentFolder = Path.GetDirectoryName(dir.FullName);
if (string.IsNullOrEmpty(parentFolder))
{
dir = null;
}
else
{
dir = _fileSystem.GetDirectoryInfo(parentFolder);
}
}

return GetDirectory("BDMV", _fileSystem.GetDirectoryInfo(path), 0);
Expand All @@ -350,7 +368,7 @@ private FileSystemMetadata GetDirectory(
FileSystemMetadata[] children = _fileSystem.GetDirectories(dir.FullName).ToArray();
foreach (FileSystemMetadata child in children)
{
if (child.Name == name)
if (string.Equals(child.Name, name, StringComparison.OrdinalIgnoreCase))
{
return child;
}
Expand Down
2 changes: 2 additions & 0 deletions Emby.Common.Implementations/BaseApplicationHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ public void RemovePlugin(IPlugin plugin)
/// </summary>
public void NotifyPendingRestart()
{
Logger.Info("App needs to be restarted.");

var changed = !HasPendingRestart;

HasPendingRestart = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ namespace Emby.Common.Implementations.EnvironmentInfo
public class EnvironmentInfo : IEnvironmentInfo
{
public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; }
public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; }

public MediaBrowser.Model.System.OperatingSystem OperatingSystem
{
get
{
if (CustomOperatingSystem.HasValue)
{
return CustomOperatingSystem.Value;
}

#if NET46
switch (Environment.OSVersion.Platform)
{
Expand Down
29 changes: 2 additions & 27 deletions Emby.Common.Implementations/IO/ManagedFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,38 +490,13 @@ public void SwapFiles(string file1, string file2)
var temp1 = Path.GetTempFileName();

// Copying over will fail against hidden files
RemoveHiddenAttribute(file1);
RemoveHiddenAttribute(file2);
SetHidden(file1, false);
SetHidden(file2, false);

CopyFile(file1, temp1, true);

CopyFile(file2, file1, true);
CopyFile(temp1, file2, true);

DeleteFile(temp1);
}

/// <summary>
/// Removes the hidden attribute.
/// </summary>
/// <param name="path">The path.</param>
private void RemoveHiddenAttribute(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException("path");
}

var currentFile = new FileInfo(path);

// This will fail if the file is hidden
if (currentFile.Exists)
{
if ((currentFile.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
currentFile.Attributes &= ~FileAttributes.Hidden;
}
}
}

public bool ContainsSubPath(string parentPath, string path)
Expand Down
20 changes: 14 additions & 6 deletions Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,12 @@ public TaskTriggerInfo[] Triggers
throw new ArgumentNullException("value");
}

SaveTriggers(value);
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
var triggerList = value.Where(i => i != null).ToArray();

InternalTriggers = value.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray();
SaveTriggers(triggerList);

InternalTriggers = triggerList.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray();
}
}

Expand Down Expand Up @@ -535,7 +538,8 @@ private string GetConfigurationFilePath()
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
private Tuple<TaskTriggerInfo, ITaskTrigger>[] LoadTriggers()
{
var settings = LoadTriggerSettings();
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
var settings = LoadTriggerSettings().Where(i => i != null).ToArray();

return settings.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray();
}
Expand All @@ -544,8 +548,12 @@ private TaskTriggerInfo[] LoadTriggerSettings()
{
try
{
return JsonSerializer.DeserializeFromFile<IEnumerable<TaskTriggerInfo>>(GetConfigurationFilePath())
.ToArray();
var list = JsonSerializer.DeserializeFromFile<IEnumerable<TaskTriggerInfo>>(GetConfigurationFilePath());

if (list != null)
{
return list.ToArray();
}
}
catch (FileNotFoundException)
{
Expand All @@ -555,8 +563,8 @@ private TaskTriggerInfo[] LoadTriggerSettings()
catch (DirectoryNotFoundException)
{
// File doesn't exist. No biggie. Return defaults.
return ScheduledTask.GetDefaultTriggers().ToArray();
}
return ScheduledTask.GetDefaultTriggers().ToArray();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Emby.Dlna/ContentDirectory/ControlHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private async Task<IEnumerable<KeyValuePair<string, string>>> HandleBrowse(IDict
}
else
{
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, item, null, null, deviceId, filter);
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, item, user, null, null, deviceId, filter);
}

provided++;
Expand All @@ -294,7 +294,7 @@ private async Task<IEnumerable<KeyValuePair<string, string>>> HandleBrowse(IDict
}
else
{
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, childItem, item, serverItem.StubType, deviceId, filter);
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, childItem, user, item, serverItem.StubType, deviceId, filter);
}
}
}
Expand Down Expand Up @@ -390,7 +390,7 @@ private async Task<IEnumerable<KeyValuePair<string, string>>> HandleSearch(IDict
}
else
{
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, i, item, serverItem.StubType, deviceId, filter);
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, i, user, item, serverItem.StubType, deviceId, filter);
}
}

Expand Down
58 changes: 43 additions & 15 deletions Emby.Dlna/Didl/DidlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public DidlBuilder(DeviceProfile profile, User user, IImageProcessor imageProces
_user = user;
}

public string GetItemDidl(DlnaOptions options, BaseItem item, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo)
public string GetItemDidl(DlnaOptions options, BaseItem item, User user, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo)
{
var settings = new XmlWriterSettings
{
Expand All @@ -86,7 +86,7 @@ public string GetItemDidl(DlnaOptions options, BaseItem item, BaseItem context,

WriteXmlRootAttributes(_profile, writer);

WriteItemElement(options, writer, item, context, null, deviceId, filter, streamInfo);
WriteItemElement(options, writer, item, user, context, null, deviceId, filter, streamInfo);

writer.WriteFullEndElement();
//writer.WriteEndDocument();
Expand All @@ -111,7 +111,15 @@ public static void WriteXmlRootAttributes(DeviceProfile profile, XmlWriter write
}
}

public void WriteItemElement(DlnaOptions options, XmlWriter writer, BaseItem item, BaseItem context, StubType? contextStubType, string deviceId, Filter filter, StreamInfo streamInfo = null)
public void WriteItemElement(DlnaOptions options,
XmlWriter writer,
BaseItem item,
User user,
BaseItem context,
StubType? contextStubType,
string deviceId,
Filter filter,
StreamInfo streamInfo = null)
{
var clientId = GetClientId(item, null);

Expand All @@ -135,7 +143,7 @@ public void WriteItemElement(DlnaOptions options, XmlWriter writer, BaseItem ite

AddGeneralProperties(item, null, context, writer, filter);

//AddBookmarkInfo(item, user, element);
AddSamsungBookmarkInfo(item, user, writer);

// refID?
// storeAttribute(itemNode, object, ClassProperties.REF_ID, false);
Expand Down Expand Up @@ -555,17 +563,37 @@ public void WriteFolderElement(XmlWriter writer, BaseItem folder, StubType? stub
writer.WriteFullEndElement();
}

//private void AddBookmarkInfo(BaseItem item, User user, XmlElement element)
//{
// var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey());

// if (userdata.PlaybackPositionTicks > 0)
// {
// var dcmInfo = element.OwnerDocument.CreateElement("sec", "dcmInfo", NS_SEC);
// dcmInfo.InnerText = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture));
// element.AppendChild(dcmInfo);
// }
//}
private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer)
{
if (!item.SupportsPositionTicksResume || item is Folder)
{
return;
}

XmlAttribute secAttribute = null;
foreach (var attribute in _profile.XmlRootAttributes)
{
if (string.Equals(attribute.Name, "xmlns:sec", StringComparison.OrdinalIgnoreCase))
{
secAttribute = attribute;
break;
}
}

// Not a samsung device
if (secAttribute == null)
{
return;
}

var userdata = _userDataManager.GetUserData(user.Id, item);

if (userdata.PlaybackPositionTicks > 0)
{
var elementValue = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture));
AddValue(writer, "sec", "dcmInfo", elementValue, secAttribute.Value);
}
}

/// <summary>
/// Adds fields used by both items and folders
Expand Down
2 changes: 1 addition & 1 deletion Emby.Dlna/PlayTo/PlayToController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ private PlaylistItem CreatePlaylistItem(BaseItem item, User user, long startPost
playlistItem.StreamUrl = playlistItem.StreamInfo.ToDlnaUrl(_serverAddress, _accessToken);

var itemXml = new DidlBuilder(profile, user, _imageProcessor, _serverAddress, _accessToken, _userDataManager, _localization, _mediaSourceManager, _logger, _libraryManager, _mediaEncoder)
.GetItemDidl(_config.GetDlnaConfiguration(), item, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo);
.GetItemDidl(_config.GetDlnaConfiguration(), item, user, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo);

playlistItem.Didl = itemXml;

Expand Down
15 changes: 15 additions & 0 deletions Emby.Dlna/Profiles/DishHopperJoeyProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ public DishHopperJoeyProfile()
IsRequired = true
}
}
},

new CodecProfile
{
Type = CodecType.VideoAudio,
Conditions = new []
{
// The device does not have any audio switching capabilities
new ProfileCondition
{
Condition = ProfileConditionType.Equals,
Property = ProfileConditionValue.IsSecondaryAudio,
Value = "false"
}
}
}
};

Expand Down
7 changes: 3 additions & 4 deletions Emby.Dlna/Profiles/LgTvProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,26 @@ public LgTvProfile()
{
Container = "ts",
VideoCodec = "h264",
AudioCodec = "aac,ac3,mp3",
AudioCodec = "aac,ac3,mp3,dca,dts",
Type = DlnaProfileType.Video
},
new DirectPlayProfile
{
Container = "mkv",
VideoCodec = "h264",
AudioCodec = "aac,ac3,mp3",
AudioCodec = "aac,ac3,mp3,dca,dts",
Type = DlnaProfileType.Video
},
new DirectPlayProfile
{
Container = "mp4",
VideoCodec = "h264,mpeg4",
AudioCodec = "aac,ac3,mp3",
AudioCodec = "aac,ac3,mp3,dca,dts",
Type = DlnaProfileType.Video
},
new DirectPlayProfile
{
Container = "mp3",
AudioCodec = "mp3",
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
Expand Down
6 changes: 3 additions & 3 deletions Emby.Dlna/Profiles/Xml/BubbleUPnp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
<DirectPlayProfile container="" type="Photo" />
</DirectPlayProfiles>
<TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
</TranscodingProfiles>
<ContainerProfiles />
<CodecProfiles />
Expand Down
6 changes: 3 additions & 3 deletions Emby.Dlna/Profiles/Xml/Default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
<DirectPlayProfile container="mp3,wma,aac,wav" type="Audio" />
</DirectPlayProfiles>
<TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
</TranscodingProfiles>
<ContainerProfiles />
<CodecProfiles />
Expand Down
6 changes: 3 additions & 3 deletions Emby.Dlna/Profiles/Xml/Denon AVR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
<DirectPlayProfile container="mp3,flac,m4a,wma" type="Audio" />
</DirectPlayProfiles>
<TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" enableSplittingOnNonKeyFrames="false" />
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
</TranscodingProfiles>
<ContainerProfiles />
<CodecProfiles />
Expand Down
Loading

0 comments on commit 7dbdb75

Please sign in to comment.