Merge pull request #4139 from BaronGreenback/Comment4
DLNA MediaRegistrar - static and commented.
This commit is contained in:
commit
d81cb3d885
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
@ -10,8 +8,16 @@ using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Emby.Dlna.MediaReceiverRegistrar
|
namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ControlHandler" />.
|
||||||
|
/// </summary>
|
||||||
public class ControlHandler : BaseControlHandler
|
public class ControlHandler : BaseControlHandler
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ControlHandler"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
public ControlHandler(IServerConfigurationManager config, ILogger logger)
|
public ControlHandler(IServerConfigurationManager config, ILogger logger)
|
||||||
: base(config, logger)
|
: base(config, logger)
|
||||||
{
|
{
|
||||||
|
@ -35,9 +41,17 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
|
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Records that the handle is authorized in the xml stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
private static void HandleIsAuthorized(XmlWriter xmlWriter)
|
private static void HandleIsAuthorized(XmlWriter xmlWriter)
|
||||||
=> xmlWriter.WriteElementString("Result", "1");
|
=> xmlWriter.WriteElementString("Result", "1");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Records that the handle is validated in the xml stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
private static void HandleIsValidated(XmlWriter xmlWriter)
|
private static void HandleIsValidated(XmlWriter xmlWriter)
|
||||||
=> xmlWriter.WriteElementString("Result", "1");
|
=> xmlWriter.WriteElementString("Result", "1");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Dlna.Service;
|
using Emby.Dlna.Service;
|
||||||
|
@ -8,10 +6,19 @@ using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Emby.Dlna.MediaReceiverRegistrar
|
namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="MediaReceiverRegistrarService" />.
|
||||||
|
/// </summary>
|
||||||
public class MediaReceiverRegistrarService : BaseService, IMediaReceiverRegistrar
|
public class MediaReceiverRegistrarService : BaseService, IMediaReceiverRegistrar
|
||||||
{
|
{
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="MediaReceiverRegistrarService"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The <see cref="ILogger{MediaReceiverRegistrarService}"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
|
||||||
|
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
|
||||||
|
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
|
||||||
public MediaReceiverRegistrarService(
|
public MediaReceiverRegistrarService(
|
||||||
ILogger<MediaReceiverRegistrarService> logger,
|
ILogger<MediaReceiverRegistrarService> logger,
|
||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
|
@ -24,7 +31,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GetServiceXml()
|
public string GetServiceXml()
|
||||||
{
|
{
|
||||||
return new MediaReceiverRegistrarXmlBuilder().GetXml();
|
return MediaReceiverRegistrarXmlBuilder.GetXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -1,79 +1,89 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Emby.Dlna.Common;
|
using Emby.Dlna.Common;
|
||||||
using Emby.Dlna.Service;
|
using Emby.Dlna.Service;
|
||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
|
|
||||||
namespace Emby.Dlna.MediaReceiverRegistrar
|
namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
{
|
{
|
||||||
public class MediaReceiverRegistrarXmlBuilder
|
/// <summary>
|
||||||
|
/// Defines the <see cref="MediaReceiverRegistrarXmlBuilder" />.
|
||||||
|
/// See https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-drmnd/5d37515e-7a63-4709-8258-8fd4e0ed4482.
|
||||||
|
/// </summary>
|
||||||
|
public static class MediaReceiverRegistrarXmlBuilder
|
||||||
{
|
{
|
||||||
public string GetXml()
|
/// <summary>
|
||||||
|
/// Retrieves an XML description of the X_MS_MediaReceiverRegistrar.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An XML representation of this service.</returns>
|
||||||
|
public static string GetXml()
|
||||||
{
|
{
|
||||||
return new ServiceXmlBuilder().GetXml(
|
return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables());
|
||||||
new ServiceActionListBuilder().GetActions(),
|
|
||||||
GetStateVariables());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The a list of all the state variables for this invocation.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
|
||||||
private static IEnumerable<StateVariable> GetStateVariables()
|
private static IEnumerable<StateVariable> GetStateVariables()
|
||||||
{
|
{
|
||||||
var list = new List<StateVariable>();
|
var list = new List<StateVariable>
|
||||||
|
|
||||||
list.Add(new StateVariable
|
|
||||||
{
|
{
|
||||||
Name = "AuthorizationGrantedUpdateID",
|
new StateVariable
|
||||||
DataType = "ui4",
|
{
|
||||||
SendsEvents = true
|
Name = "AuthorizationGrantedUpdateID",
|
||||||
});
|
DataType = "ui4",
|
||||||
|
SendsEvents = true
|
||||||
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_DeviceID",
|
Name = "A_ARG_TYPE_DeviceID",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "AuthorizationDeniedUpdateID",
|
Name = "AuthorizationDeniedUpdateID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = true
|
SendsEvents = true
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "ValidationSucceededUpdateID",
|
Name = "ValidationSucceededUpdateID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = true
|
SendsEvents = true
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_RegistrationRespMsg",
|
Name = "A_ARG_TYPE_RegistrationRespMsg",
|
||||||
DataType = "bin.base64",
|
DataType = "bin.base64",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_RegistrationReqMsg",
|
Name = "A_ARG_TYPE_RegistrationReqMsg",
|
||||||
DataType = "bin.base64",
|
DataType = "bin.base64",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "ValidationRevokedUpdateID",
|
Name = "ValidationRevokedUpdateID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = true
|
SendsEvents = true
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_Result",
|
Name = "A_ARG_TYPE_Result",
|
||||||
DataType = "int",
|
DataType = "int",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Emby.Dlna.Common;
|
using Emby.Dlna.Common;
|
||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
|
|
||||||
namespace Emby.Dlna.MediaReceiverRegistrar
|
namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
{
|
{
|
||||||
public class ServiceActionListBuilder
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ServiceActionListBuilder" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class ServiceActionListBuilder
|
||||||
{
|
{
|
||||||
public IEnumerable<ServiceAction> GetActions()
|
/// <summary>
|
||||||
|
/// Returns a list of services that this instance provides.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
|
||||||
|
public static IEnumerable<ServiceAction> GetActions()
|
||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
{
|
{
|
||||||
|
@ -21,6 +27,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "IsValidated".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetIsValidated()
|
private static ServiceAction GetIsValidated()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -43,6 +53,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "IsAuthorized".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetIsAuthorized()
|
private static ServiceAction GetIsAuthorized()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -65,6 +79,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "RegisterDevice".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetRegisterDevice()
|
private static ServiceAction GetRegisterDevice()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -87,6 +105,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetValidationSucceededUpdateID".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetGetValidationSucceededUpdateID()
|
private static ServiceAction GetGetValidationSucceededUpdateID()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -103,7 +125,11 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetGetAuthorizationDeniedUpdateID()
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetGetAuthorizationDeniedUpdateID".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetGetAuthorizationDeniedUpdateID()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
@ -119,7 +145,11 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetGetValidationRevokedUpdateID()
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetValidationRevokedUpdateID".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetGetValidationRevokedUpdateID()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
@ -135,7 +165,11 @@ namespace Emby.Dlna.MediaReceiverRegistrar
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetGetAuthorizationGrantedUpdateID()
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetAuthorizationGrantedUpdateID".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetGetAuthorizationGrantedUpdateID()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,10 +60,8 @@ namespace Emby.Dlna.Service
|
||||||
Async = true
|
Async = true
|
||||||
};
|
};
|
||||||
|
|
||||||
using (var reader = XmlReader.Create(streamReader, readerSettings))
|
using var reader = XmlReader.Create(streamReader, readerSettings);
|
||||||
{
|
requestInfo = await ParseRequestAsync(reader).ConfigureAwait(false);
|
||||||
requestInfo = await ParseRequestAsync(reader).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.LogDebug("Received control request {0}", requestInfo.LocalName);
|
Logger.LogDebug("Received control request {0}", requestInfo.LocalName);
|
||||||
|
@ -124,10 +122,8 @@ namespace Emby.Dlna.Service
|
||||||
{
|
{
|
||||||
if (!reader.IsEmptyElement)
|
if (!reader.IsEmptyElement)
|
||||||
{
|
{
|
||||||
using (var subReader = reader.ReadSubtree())
|
using var subReader = reader.ReadSubtree();
|
||||||
{
|
return await ParseBodyTagAsync(subReader).ConfigureAwait(false);
|
||||||
return await ParseBodyTagAsync(subReader).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -171,11 +167,8 @@ namespace Emby.Dlna.Service
|
||||||
if (!reader.IsEmptyElement)
|
if (!reader.IsEmptyElement)
|
||||||
{
|
{
|
||||||
var result = new ControlRequestInfo(localName, namespaceURI);
|
var result = new ControlRequestInfo(localName, namespaceURI);
|
||||||
using (var subReader = reader.ReadSubtree())
|
using var subReader = reader.ReadSubtree();
|
||||||
{
|
await ParseFirstBodyChildAsync(subReader, result.Headers).ConfigureAwait(false);
|
||||||
await ParseFirstBodyChildAsync(subReader, result.Headers).ConfigureAwait(false);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user