Skip to content

Commit 6cbe264

Browse files
dlna fixes
1 parent 6a765f5 commit 6cbe264

File tree

6 files changed

+79
-44
lines changed

6 files changed

+79
-44
lines changed

MediaBrowser.Api/Dlna/DlnaServerService.cs

+25-13
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,31 @@ public class GetDescriptionXml
1818
public string UuId { get; set; }
1919
}
2020

21-
[Route("/Dlna/contentdirectory/contentdirectory.xml", "GET", Summary = "Gets dlna content directory xml")]
22-
[Route("/Dlna/contentdirectory/contentdirectory", "GET", Summary = "Gets dlna content directory xml")]
21+
[Route("/Dlna/{UuId}/contentdirectory/contentdirectory.xml", "GET", Summary = "Gets dlna content directory xml")]
22+
[Route("/Dlna/{UuId}/contentdirectory/contentdirectory", "GET", Summary = "Gets dlna content directory xml")]
2323
public class GetContentDirectory
2424
{
25+
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
26+
public string UuId { get; set; }
2527
}
2628

27-
[Route("/Dlna/connectionmanager/connectionmanager.xml", "GET", Summary = "Gets dlna connection manager xml")]
28-
[Route("/Dlna/connectionmanager/connectionmanager", "GET", Summary = "Gets dlna connection manager xml")]
29+
[Route("/Dlna/{UuId}/connectionmanager/connectionmanager.xml", "GET", Summary = "Gets dlna connection manager xml")]
30+
[Route("/Dlna/{UuId}/connectionmanager/connectionmanager", "GET", Summary = "Gets dlna connection manager xml")]
2931
public class GetConnnectionManager
3032
{
33+
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
34+
public string UuId { get; set; }
3135
}
3236

33-
[Route("/Dlna/mediareceiverregistrar/mediareceiverregistrar.xml", "GET", Summary = "Gets dlna mediareceiverregistrar xml")]
34-
[Route("/Dlna/mediareceiverregistrar/mediareceiverregistrar", "GET", Summary = "Gets dlna mediareceiverregistrar xml")]
37+
[Route("/Dlna/{UuId}/mediareceiverregistrar/mediareceiverregistrar.xml", "GET", Summary = "Gets dlna mediareceiverregistrar xml")]
38+
[Route("/Dlna/{UuId}/mediareceiverregistrar/mediareceiverregistrar", "GET", Summary = "Gets dlna mediareceiverregistrar xml")]
3539
public class GetMediaReceiverRegistrar
3640
{
41+
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
42+
public string UuId { get; set; }
3743
}
3844

39-
[Route("/Dlna/contentdirectory/{UuId}/control", "POST", Summary = "Processes a control request")]
45+
[Route("/Dlna/{UuId}/contentdirectory/control", "POST", Summary = "Processes a control request")]
4046
public class ProcessContentDirectoryControlRequest : IRequiresRequestStream
4147
{
4248
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
@@ -45,7 +51,7 @@ public class ProcessContentDirectoryControlRequest : IRequiresRequestStream
4551
public Stream RequestStream { get; set; }
4652
}
4753

48-
[Route("/Dlna/connectionmanager/{UuId}/control", "POST", Summary = "Processes a control request")]
54+
[Route("/Dlna/{UuId}/connectionmanager/control", "POST", Summary = "Processes a control request")]
4955
public class ProcessConnectionManagerControlRequest : IRequiresRequestStream
5056
{
5157
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
@@ -54,7 +60,7 @@ public class ProcessConnectionManagerControlRequest : IRequiresRequestStream
5460
public Stream RequestStream { get; set; }
5561
}
5662

57-
[Route("/Dlna/mediareceiverregistrar/{UuId}/control", "POST", Summary = "Processes a control request")]
63+
[Route("/Dlna/{UuId}/mediareceiverregistrar/control", "POST", Summary = "Processes a control request")]
5864
public class ProcessMediaReceiverRegistrarControlRequest : IRequiresRequestStream
5965
{
6066
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
@@ -63,30 +69,34 @@ public class ProcessMediaReceiverRegistrarControlRequest : IRequiresRequestStrea
6369
public Stream RequestStream { get; set; }
6470
}
6571

66-
[Route("/Dlna/mediareceiverregistrar/{UuId}/events", Summary = "Processes an event subscription request")]
72+
[Route("/Dlna/{UuId}/mediareceiverregistrar/events", Summary = "Processes an event subscription request")]
6773
public class ProcessMediaReceiverRegistrarEventRequest
6874
{
6975
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
7076
public string UuId { get; set; }
7177
}
7278

73-
[Route("/Dlna/contentdirectory/{UuId}/events", Summary = "Processes an event subscription request")]
79+
[Route("/Dlna/{UuId}/contentdirectory/events", Summary = "Processes an event subscription request")]
7480
public class ProcessContentDirectoryEventRequest
7581
{
7682
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
7783
public string UuId { get; set; }
7884
}
7985

80-
[Route("/Dlna/connectionmanager/{UuId}/events", Summary = "Processes an event subscription request")]
86+
[Route("/Dlna/{UuId}/connectionmanager/events", Summary = "Processes an event subscription request")]
8187
public class ProcessConnectionManagerEventRequest
8288
{
8389
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
8490
public string UuId { get; set; }
8591
}
8692

93+
[Route("/Dlna/{UuId}/icons/{Filename}", "GET", Summary = "Gets a server icon")]
8794
[Route("/Dlna/icons/{Filename}", "GET", Summary = "Gets a server icon")]
8895
public class GetIcon
8996
{
97+
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
98+
public string UuId { get; set; }
99+
90100
[ApiMember(Name = "Filename", Description = "The icon filename", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
91101
public string Filename { get; set; }
92102
}
@@ -108,7 +118,9 @@ public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDire
108118

109119
public object Get(GetDescriptionXml request)
110120
{
111-
var xml = _dlnaManager.GetServerDescriptionXml(GetRequestHeaders(), request.UuId);
121+
var url = Request.AbsoluteUri;
122+
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
123+
var xml = _dlnaManager.GetServerDescriptionXml(GetRequestHeaders(), request.UuId, serverAddress);
112124

113125
return ResultFactory.GetResult(xml, "text/xml");
114126
}

MediaBrowser.Controller/Dlna/IDlnaManager.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ public interface IDlnaManager
6262
/// </summary>
6363
/// <param name="headers">The headers.</param>
6464
/// <param name="serverUuId">The server uu identifier.</param>
65+
/// <param name="serverAddress">The server address.</param>
6566
/// <returns>System.String.</returns>
66-
string GetServerDescriptionXml(IDictionary<string, string> headers, string serverUuId);
67+
string GetServerDescriptionXml(IDictionary<string, string> headers, string serverUuId, string serverAddress);
6768

6869
/// <summary>
6970
/// Gets the icon.

MediaBrowser.Dlna/DlnaManager.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,12 @@ class InternalProfileInfo
475475
internal string Path { get; set; }
476476
}
477477

478-
public string GetServerDescriptionXml(IDictionary<string, string> headers, string serverUuId)
478+
public string GetServerDescriptionXml(IDictionary<string, string> headers, string serverUuId, string serverAddress)
479479
{
480480
var profile = GetProfile(headers) ??
481481
GetDefaultProfile();
482482

483-
return new DescriptionXmlBuilder(profile, serverUuId, "").GetXml();
483+
return new DescriptionXmlBuilder(profile, serverUuId, serverAddress).GetXml();
484484
}
485485

486486
public ImageStream GetIcon(string filename)

MediaBrowser.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ public IEnumerable<ServiceAction> GetActions()
1111
{
1212
GetIsValidated(),
1313
GetIsAuthorized(),
14-
//GetRegisterDevice(),
15-
//GetGetAuthorizationDeniedUpdateID(),
16-
//GetGetAuthorizationGrantedUpdateID(),
17-
//GetGetValidationRevokedUpdateID(),
18-
//GetGetValidationSucceededUpdateID()
14+
GetRegisterDevice(),
15+
GetGetAuthorizationDeniedUpdateID(),
16+
GetGetAuthorizationGrantedUpdateID(),
17+
GetGetValidationRevokedUpdateID(),
18+
GetGetValidationSucceededUpdateID()
1919
};
2020

2121
return list;

MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs

+41-21
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string ser
2323
throw new ArgumentNullException("serverUdn");
2424
}
2525

26+
if (string.IsNullOrWhiteSpace(serverAddress))
27+
{
28+
throw new ArgumentNullException("serverAddress");
29+
}
30+
2631
_profile = profile;
2732
_serverUdn = serverUdn;
2833
_serverAddress = serverAddress;
@@ -81,8 +86,8 @@ private void AppendDeviceProperties(StringBuilder builder)
8186
builder.Append("<modelURL>" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>");
8287
builder.Append("<serialNumber>" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + "</serialNumber>");
8388

84-
//builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
85-
89+
builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
90+
8691
if (!string.IsNullOrWhiteSpace(_profile.SonyAggregationFlags))
8792
{
8893
builder.Append("<av:aggregationFlags xmlns:av=\"urn:schemas-sony-com:av\">" + SecurityElement.Escape(_profile.SonyAggregationFlags) + "</av:aggregationFlags>");
@@ -101,7 +106,7 @@ private void AppendIconList(StringBuilder builder)
101106
builder.Append("<width>" + SecurityElement.Escape(icon.Width.ToString(_usCulture)) + "</width>");
102107
builder.Append("<height>" + SecurityElement.Escape(icon.Height.ToString(_usCulture)) + "</height>");
103108
builder.Append("<depth>" + SecurityElement.Escape(icon.Depth ?? string.Empty) + "</depth>");
104-
builder.Append("<url>" + SecurityElement.Escape(icon.Url ?? string.Empty) + "</url>");
109+
builder.Append("<url>" + BuildUrl(icon.Url) + "</url>");
105110

106111
builder.Append("</icon>");
107112
}
@@ -119,16 +124,31 @@ private void AppendServiceList(StringBuilder builder)
119124

120125
builder.Append("<serviceType>" + SecurityElement.Escape(service.ServiceType ?? string.Empty) + "</serviceType>");
121126
builder.Append("<serviceId>" + SecurityElement.Escape(service.ServiceId ?? string.Empty) + "</serviceId>");
122-
builder.Append("<SCPDURL>" + SecurityElement.Escape(service.ScpdUrl ?? string.Empty) + "</SCPDURL>");
123-
builder.Append("<controlURL>" + SecurityElement.Escape(service.ControlUrl ?? string.Empty) + "</controlURL>");
124-
builder.Append("<eventSubURL>" + SecurityElement.Escape(service.EventSubUrl ?? string.Empty) + "</eventSubURL>");
127+
builder.Append("<SCPDURL>" + BuildUrl(service.ScpdUrl) + "</SCPDURL>");
128+
builder.Append("<controlURL>" + BuildUrl(service.ControlUrl) + "</controlURL>");
129+
builder.Append("<eventSubURL>" + BuildUrl(service.EventSubUrl) + "</eventSubURL>");
125130

126131
builder.Append("</service>");
127132
}
128133

129134
builder.Append("</serviceList>");
130135
}
131136

137+
private string BuildUrl(string url)
138+
{
139+
if (string.IsNullOrWhiteSpace(url))
140+
{
141+
return string.Empty;
142+
}
143+
144+
url = url.TrimStart('/');
145+
146+
url = "/dlna/" + _serverUdn + "/" + url;
147+
//url = _serverAddress.TrimEnd('/') + url;
148+
149+
return SecurityElement.Escape(url);
150+
}
151+
132152
private IEnumerable<DeviceIcon> GetIcons()
133153
{
134154
var list = new List<DeviceIcon>();
@@ -139,7 +159,7 @@ private IEnumerable<DeviceIcon> GetIcons()
139159
Depth = "24",
140160
Width = 240,
141161
Height = 240,
142-
Url = "/dlna/icons/logo240.png"
162+
Url = "icons/logo240.png"
143163
});
144164

145165
list.Add(new DeviceIcon
@@ -148,7 +168,7 @@ private IEnumerable<DeviceIcon> GetIcons()
148168
Depth = "24",
149169
Width = 240,
150170
Height = 240,
151-
Url = "/dlna/icons/logo240.jpg"
171+
Url = "icons/logo240.jpg"
152172
});
153173

154174
list.Add(new DeviceIcon
@@ -157,7 +177,7 @@ private IEnumerable<DeviceIcon> GetIcons()
157177
Depth = "24",
158178
Width = 120,
159179
Height = 120,
160-
Url = "/dlna/icons/logo120.png"
180+
Url = "icons/logo120.png"
161181
});
162182

163183
list.Add(new DeviceIcon
@@ -166,7 +186,7 @@ private IEnumerable<DeviceIcon> GetIcons()
166186
Depth = "24",
167187
Width = 120,
168188
Height = 120,
169-
Url = "/dlna/icons/logo120.jpg"
189+
Url = "icons/logo120.jpg"
170190
});
171191

172192
list.Add(new DeviceIcon
@@ -175,7 +195,7 @@ private IEnumerable<DeviceIcon> GetIcons()
175195
Depth = "24",
176196
Width = 48,
177197
Height = 48,
178-
Url = "/dlna/icons/logo48.png"
198+
Url = "icons/logo48.png"
179199
});
180200

181201
list.Add(new DeviceIcon
@@ -184,7 +204,7 @@ private IEnumerable<DeviceIcon> GetIcons()
184204
Depth = "24",
185205
Width = 48,
186206
Height = 48,
187-
Url = "/dlna/icons/logo48.jpg"
207+
Url = "icons/logo48.jpg"
188208
});
189209

190210
return list;
@@ -198,27 +218,27 @@ private IEnumerable<DeviceService> GetServices()
198218
{
199219
ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1",
200220
ServiceId = "urn:upnp-org:serviceId:ContentDirectory",
201-
ScpdUrl = "/dlna/contentdirectory/contentdirectory.xml",
202-
ControlUrl = "/dlna/contentdirectory/" + _serverUdn + "/control",
203-
EventSubUrl = "/dlna/contentdirectory/" + _serverUdn + "/events"
221+
ScpdUrl = "contentdirectory/contentdirectory.xml",
222+
ControlUrl = "contentdirectory/control",
223+
EventSubUrl = "contentdirectory/events"
204224
});
205225

206226
list.Add(new DeviceService
207227
{
208228
ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1",
209229
ServiceId = "urn:upnp-org:serviceId:ConnectionManager",
210-
ScpdUrl = "/dlna/connectionmanager/connectionmanager.xml",
211-
ControlUrl = "/dlna/connectionmanager/" + _serverUdn + "/control",
212-
EventSubUrl = "/dlna/connectionmanager/" + _serverUdn + "/events"
230+
ScpdUrl = "connectionmanager/connectionmanager.xml",
231+
ControlUrl = "connectionmanager/control",
232+
EventSubUrl = "connectionmanager/events"
213233
});
214234

215235
list.Add(new DeviceService
216236
{
217237
ServiceType = "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1",
218238
ServiceId = "urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar",
219-
ScpdUrl = "/dlna/mediareceiverregistrar/mediareceiverregistrar.xml",
220-
ControlUrl = "/dlna/mediareceiverregistrar/" + _serverUdn + "/control",
221-
EventSubUrl = "/dlna/mediareceiverregistrar/" + _serverUdn + "/events"
239+
ScpdUrl = "mediareceiverregistrar/mediareceiverregistrar.xml",
240+
ControlUrl = "mediareceiverregistrar/control",
241+
EventSubUrl = "mediareceiverregistrar/events"
222242
});
223243

224244
return list;

MediaBrowser.WebDashboard/dashboard-ui/scripts/musicartists.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
$('.listTopPaging', page).html(pagingHtml).trigger('create');
4646

4747
updateFilterControls(page);
48+
var trigger = false;
4849

4950
if (view == "List") {
5051

@@ -53,6 +54,7 @@
5354
context: 'music',
5455
sortBy: query.SortBy
5556
});
57+
trigger = true;
5658
}
5759
else if (view == "Poster") {
5860
html = LibraryBrowser.getPosterViewHtml({
@@ -79,7 +81,7 @@
7981
});
8082
}
8183

82-
var elem = $('#items', page).html(html).lazyChildren();
84+
var elem = $('.itemsContainer', page).html(html).lazyChildren();
8385

8486
if (trigger) {
8587
elem.trigger('create');
@@ -192,7 +194,7 @@
192194
}).on('pagebeforeshow', "#musicArtistsPage", function () {
193195

194196
var page = this;
195-
197+
196198
query.ParentId = LibraryMenu.getTopParentId();
197199

198200
var limit = LibraryBrowser.getDefaultPageSize(pageSizeKey, 100);

0 commit comments

Comments
 (0)