mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-28 19:38:26 +01:00
dlna fixes
This commit is contained in:
@@ -66,8 +66,8 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
}
|
||||
}
|
||||
|
||||
private string _transportState = String.Empty;
|
||||
public string TransportState
|
||||
private TRANSPORTSTATE _transportState = TRANSPORTSTATE.STOPPED;
|
||||
public TRANSPORTSTATE TransportState
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -80,8 +80,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
|
||||
_transportState = value;
|
||||
|
||||
if (value == TRANSPORTSTATE.PLAYING || value == TRANSPORTSTATE.STOPPED)
|
||||
NotifyPlaybackChanged(value == TRANSPORTSTATE.STOPPED);
|
||||
NotifyPlaybackChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +373,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
.ConfigureAwait(false);
|
||||
|
||||
await Task.Delay(50).ConfigureAwait(false);
|
||||
TransportState = "PAUSED_PLAYBACK";
|
||||
TransportState = TRANSPORTSTATE.PAUSED_PLAYBACK;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -492,7 +491,14 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
var transportStateValue = transportState == null ? null : transportState.Value;
|
||||
|
||||
if (transportStateValue != null)
|
||||
TransportState = transportStateValue;
|
||||
{
|
||||
TRANSPORTSTATE state;
|
||||
|
||||
if (Enum.TryParse(transportStateValue, true, out state))
|
||||
{
|
||||
TransportState = state;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTime = DateTime.UtcNow;
|
||||
}
|
||||
@@ -857,13 +863,13 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
public event EventHandler<TransportStateEventArgs> PlaybackChanged;
|
||||
public event EventHandler<CurrentIdEventArgs> CurrentIdChanged;
|
||||
|
||||
private void NotifyPlaybackChanged(bool value)
|
||||
private void NotifyPlaybackChanged(TRANSPORTSTATE state)
|
||||
{
|
||||
if (PlaybackChanged != null)
|
||||
{
|
||||
PlaybackChanged.Invoke(this, new TransportStateEventArgs
|
||||
{
|
||||
Stopped = IsStopped
|
||||
State = state
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -895,14 +901,14 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
return String.Format("{0} - {1}", Properties.Name, Properties.BaseUrl);
|
||||
}
|
||||
|
||||
private class TRANSPORTSTATE
|
||||
{
|
||||
public const string STOPPED = "STOPPED";
|
||||
public const string PLAYING = "PLAYING";
|
||||
public const string TRANSITIONING = "TRANSITIONING";
|
||||
public const string PAUSED_PLAYBACK = "PAUSED_PLAYBACK";
|
||||
public const string PAUSED = "PAUSED";
|
||||
}
|
||||
}
|
||||
|
||||
public enum TRANSPORTSTATE
|
||||
{
|
||||
STOPPED,
|
||||
PLAYING,
|
||||
TRANSITIONING,
|
||||
PAUSED_PLAYBACK,
|
||||
PAUSED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
if (_currentItem == null)
|
||||
return;
|
||||
|
||||
if (e.Stopped == false)
|
||||
if (e.State == TRANSPORTSTATE.STOPPED)
|
||||
await ReportProgress().ConfigureAwait(false);
|
||||
|
||||
else if (e.Stopped && _playbackStarted)
|
||||
else if (e.State == TRANSPORTSTATE.STOPPED && _playbackStarted)
|
||||
{
|
||||
_playbackStarted = false;
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||
{
|
||||
public class TransportStateEventArgs : EventArgs
|
||||
{
|
||||
public bool Stopped { get; set; }
|
||||
public TRANSPORTSTATE State { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace MediaBrowser.Dlna.Server
|
||||
{
|
||||
var id = sparams["ObjectID"];
|
||||
|
||||
var item = _libraryManager.GetItemById(new Guid(id));
|
||||
var item = GetItemFromObjectId(id, user);
|
||||
|
||||
var newbookmark = int.Parse(sparams["PosSecond"], _usCulture);
|
||||
|
||||
@@ -265,9 +265,7 @@ namespace MediaBrowser.Dlna.Server
|
||||
didl.SetAttribute("xmlns:sec", NS_SEC);
|
||||
result.AppendChild(didl);
|
||||
|
||||
var folder = string.IsNullOrWhiteSpace(id) || string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)
|
||||
? user.RootFolder
|
||||
: (Folder)_libraryManager.GetItemById(new Guid(id));
|
||||
var folder = (Folder)GetItemFromObjectId(id, user);
|
||||
|
||||
var children = GetChildrenSorted(folder, user).ToList();
|
||||
|
||||
@@ -328,6 +326,17 @@ namespace MediaBrowser.Dlna.Server
|
||||
return _libraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending);
|
||||
}
|
||||
|
||||
private BaseItem GetItemFromObjectId(string id, User user)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(id) || string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)
|
||||
|
||||
// Samsung sometimes uses 1 as root
|
||||
|| string.Equals(id, "1", StringComparison.OrdinalIgnoreCase)
|
||||
|
||||
? user.RootFolder
|
||||
: _libraryManager.GetItemById(new Guid(id));
|
||||
}
|
||||
|
||||
private void Browse_AddFolder(XmlDocument result, Folder f, int childCount)
|
||||
{
|
||||
var container = result.CreateElement(string.Empty, "container", NS_DIDL);
|
||||
|
||||
@@ -12,9 +12,11 @@ namespace MediaBrowser.Dlna.Server
|
||||
GetGetSystemUpdateIDAction(),
|
||||
GetSearchCapabilitiesAction(),
|
||||
GetSortCapabilitiesAction(),
|
||||
GetSearchAction(),
|
||||
GetBrowseAction(),
|
||||
GetX_GetFeatureListAction(),
|
||||
GetXSetBookmarkAction()
|
||||
GetXSetBookmarkAction(),
|
||||
GetBrowseByLetterAction()
|
||||
};
|
||||
|
||||
return list;
|
||||
@@ -88,6 +90,86 @@ namespace MediaBrowser.Dlna.Server
|
||||
return action;
|
||||
}
|
||||
|
||||
private ServiceAction GetSearchAction()
|
||||
{
|
||||
var action = new ServiceAction
|
||||
{
|
||||
Name = "Search"
|
||||
};
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "ContainerID",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_ObjectID"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "SearchCriteria",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_SearchCriteria"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "Filter",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Filter"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "StartingIndex",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Index"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "RequestedCount",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Count"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "SortCriteria",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_SortCriteria"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "Result",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Result"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "NumberReturned",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Count"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "TotalMatches",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Count"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "UpdateID",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_UpdateID"
|
||||
});
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
private ServiceAction GetBrowseAction()
|
||||
{
|
||||
var action = new ServiceAction
|
||||
@@ -168,6 +250,93 @@ namespace MediaBrowser.Dlna.Server
|
||||
return action;
|
||||
}
|
||||
|
||||
private ServiceAction GetBrowseByLetterAction()
|
||||
{
|
||||
var action = new ServiceAction
|
||||
{
|
||||
Name = "X_BrowseByLetter"
|
||||
};
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "ObjectID",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_ObjectID"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "BrowseFlag",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_BrowseFlag"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "Filter",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Filter"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "StartingLetter",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_BrowseLetter"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "RequestedCount",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Count"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "SortCriteria",
|
||||
Direction = "in",
|
||||
RelatedStateVariable = "A_ARG_TYPE_SortCriteria"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "Result",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Result"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "NumberReturned",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Count"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "TotalMatches",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Count"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "UpdateID",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_UpdateID"
|
||||
});
|
||||
|
||||
action.ArgumentList.Add(new Argument
|
||||
{
|
||||
Name = "StartingIndex",
|
||||
Direction = "out",
|
||||
RelatedStateVariable = "A_ARG_TYPE_Index"
|
||||
});
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
private ServiceAction GetXSetBookmarkAction()
|
||||
{
|
||||
var action = new ServiceAction
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace MediaBrowser.Dlna.Server
|
||||
|
||||
private void RespondToSearch(IPEndPoint endpoint, string req)
|
||||
{
|
||||
if (req == "ssdp:all")
|
||||
if (string.Equals(req, "ssdp:all", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
req = null;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace MediaBrowser.Dlna.Server
|
||||
|
||||
SendDatagram(endpoint, dev.Address, msg, false);
|
||||
|
||||
_logger.Info("{1} - Responded to a {0} request", dev.Type, endpoint);
|
||||
_logger.Info("{1} - Responded to a {0} request to {2}", dev.Type, endpoint, dev.Address.ToString());
|
||||
}
|
||||
|
||||
private void SendDatagram(IPEndPoint endpoint, IPAddress localAddress, string msg, bool sticky)
|
||||
|
||||
Reference in New Issue
Block a user