support api without /mediabrowser

This commit is contained in:
Luke Pulverenti 2015-01-17 14:30:23 -05:00
parent 5f3c2f68b0
commit a8da86d059
15 changed files with 71 additions and 112 deletions

View File

@ -857,7 +857,7 @@ namespace MediaBrowser.Api.Playback
{ {
if (SupportsThrottleWithStream) if (SupportsThrottleWithStream)
{ {
var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/mediabrowser/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId;
url += "&transcodingJobId=" + transcodingJobId; url += "&transcodingJobId=" + transcodingJobId;

View File

@ -625,7 +625,7 @@ namespace MediaBrowser.Api.Playback.Hls
protected override string GetCommandLineArguments(string outputPath, string transcodingJobId, StreamState state, bool isEncoding) protected override string GetCommandLineArguments(string outputPath, string transcodingJobId, StreamState state, bool isEncoding)
{ {
// test url http://192.168.1.2:8096/mediabrowser/videos/233e8905d559a8f230db9bffd2ac9d6d/master.mpd?mediasourceid=233e8905d559a8f230db9bffd2ac9d6d&videocodec=h264&audiocodec=aac&maxwidth=1280&videobitrate=500000&audiobitrate=128000&profile=baseline&level=3 // test url http://192.168.1.2:8096/videos/233e8905d559a8f230db9bffd2ac9d6d/master.mpd?mediasourceid=233e8905d559a8f230db9bffd2ac9d6d&videocodec=h264&audiocodec=aac&maxwidth=1280&videobitrate=500000&audiobitrate=128000&profile=baseline&level=3
// Good info on i-frames http://blog.streamroot.io/encode-multi-bitrate-videos-mpeg-dash-mse-based-media-players/ // Good info on i-frames http://blog.streamroot.io/encode-multi-bitrate-videos-mpeg-dash-mse-based-media-players/
var threads = GetNumberOfThreads(state, false); var threads = GetNumberOfThreads(state, false);

View File

@ -18,12 +18,6 @@ namespace MediaBrowser.Controller
/// <returns>SystemInfo.</returns> /// <returns>SystemInfo.</returns>
SystemInfo GetSystemInfo(); SystemInfo GetSystemInfo();
/// <summary>
/// Gets the name of the web application.
/// </summary>
/// <value>The name of the web application.</value>
string WebApplicationName { get; }
/// <summary> /// <summary>
/// Gets a value indicating whether [supports automatic run at startup]. /// Gets a value indicating whether [supports automatic run at startup].
/// </summary> /// </summary>
@ -36,28 +30,6 @@ namespace MediaBrowser.Controller
/// <value>The HTTP server port.</value> /// <value>The HTTP server port.</value>
int HttpServerPort { get; } int HttpServerPort { get; }
/// <summary>
/// Gets the HTTPS server port.
/// </summary>
/// <value>The HTTPS server port.</value>
int HttpsServerPort { get; }
/// <summary>
/// Gets the value indiciating if an https port should be hosted.
/// </summary>
/// <value>
/// The value indiciating if an https port should be hosted.
/// </value>
bool UseHttps { get; }
/// <summary>
/// Gets the value pointing to the file system where the ssl certiifcate is located.
/// </summary>
/// <value>
/// The value pointing to the file system where the ssl certiifcate is located.
/// </value>
string CertificatePath { get; }
/// <summary> /// <summary>
/// Gets a value indicating whether this instance has update available. /// Gets a value indicating whether this instance has update available.
/// </summary> /// </summary>

View File

@ -165,7 +165,7 @@ namespace MediaBrowser.Dlna.Main
{ {
var guid = address.GetMD5(); var guid = address.GetMD5();
var descriptorURI = "/mediabrowser/dlna/" + guid.ToString("N") + "/description.xml"; var descriptorURI = "/dlna/" + guid.ToString("N") + "/description.xml";
var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _config.Configuration.HttpServerPortNumber, descriptorURI)); var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _config.Configuration.HttpServerPortNumber, descriptorURI));

View File

@ -139,7 +139,7 @@ namespace MediaBrowser.Dlna.Server
Depth = "24", Depth = "24",
Width = 240, Width = 240,
Height = 240, Height = 240,
Url = "/mediabrowser/dlna/icons/logo240.png" Url = "/dlna/icons/logo240.png"
}); });
list.Add(new DeviceIcon list.Add(new DeviceIcon
@ -148,7 +148,7 @@ namespace MediaBrowser.Dlna.Server
Depth = "24", Depth = "24",
Width = 240, Width = 240,
Height = 240, Height = 240,
Url = "/mediabrowser/dlna/icons/logo240.jpg" Url = "/dlna/icons/logo240.jpg"
}); });
list.Add(new DeviceIcon list.Add(new DeviceIcon
@ -157,7 +157,7 @@ namespace MediaBrowser.Dlna.Server
Depth = "24", Depth = "24",
Width = 120, Width = 120,
Height = 120, Height = 120,
Url = "/mediabrowser/dlna/icons/logo120.png" Url = "/dlna/icons/logo120.png"
}); });
list.Add(new DeviceIcon list.Add(new DeviceIcon
@ -166,7 +166,7 @@ namespace MediaBrowser.Dlna.Server
Depth = "24", Depth = "24",
Width = 120, Width = 120,
Height = 120, Height = 120,
Url = "/mediabrowser/dlna/icons/logo120.jpg" Url = "/dlna/icons/logo120.jpg"
}); });
list.Add(new DeviceIcon list.Add(new DeviceIcon
@ -175,7 +175,7 @@ namespace MediaBrowser.Dlna.Server
Depth = "24", Depth = "24",
Width = 48, Width = 48,
Height = 48, Height = 48,
Url = "/mediabrowser/dlna/icons/logo48.png" Url = "/dlna/icons/logo48.png"
}); });
list.Add(new DeviceIcon list.Add(new DeviceIcon
@ -184,7 +184,7 @@ namespace MediaBrowser.Dlna.Server
Depth = "24", Depth = "24",
Width = 48, Width = 48,
Height = 48, Height = 48,
Url = "/mediabrowser/dlna/icons/logo48.jpg" Url = "/dlna/icons/logo48.jpg"
}); });
return list; return list;
@ -198,18 +198,18 @@ namespace MediaBrowser.Dlna.Server
{ {
ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1",
ServiceId = "urn:upnp-org:serviceId:ContentDirectory", ServiceId = "urn:upnp-org:serviceId:ContentDirectory",
ScpdUrl = "/mediabrowser/dlna/contentdirectory/contentdirectory.xml", ScpdUrl = "/dlna/contentdirectory/contentdirectory.xml",
ControlUrl = "/mediabrowser/dlna/contentdirectory/" + _serverUdn + "/control", ControlUrl = "/dlna/contentdirectory/" + _serverUdn + "/control",
EventSubUrl = "/mediabrowser/dlna/contentdirectory/" + _serverUdn + "/events" EventSubUrl = "/dlna/contentdirectory/" + _serverUdn + "/events"
}); });
list.Add(new DeviceService list.Add(new DeviceService
{ {
ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1",
ServiceId = "urn:upnp-org:serviceId:ConnectionManager", ServiceId = "urn:upnp-org:serviceId:ConnectionManager",
ScpdUrl = "/mediabrowser/dlna/connectionmanager/connectionmanager.xml", ScpdUrl = "/dlna/connectionmanager/connectionmanager.xml",
ControlUrl = "/mediabrowser/dlna/connectionmanager/" + _serverUdn + "/control", ControlUrl = "/dlna/connectionmanager/" + _serverUdn + "/control",
EventSubUrl = "/mediabrowser/dlna/connectionmanager/" + _serverUdn + "/events" EventSubUrl = "/dlna/connectionmanager/" + _serverUdn + "/events"
}); });
return list; return list;

View File

@ -461,7 +461,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
// { // {
// if (SupportsThrottleWithStream) // if (SupportsThrottleWithStream)
// { // {
// var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/mediabrowser/videos/" + job.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + job.Request.MediaSourceId; // var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + job.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + job.Request.MediaSourceId;
// url += "&transcodingJobId=" + transcodingJobId; // url += "&transcodingJobId=" + transcodingJobId;

View File

@ -122,18 +122,6 @@ namespace MediaBrowser.Model.System
/// <value>The HTTP server port number.</value> /// <value>The HTTP server port number.</value>
public int HttpServerPortNumber { get; set; } public int HttpServerPortNumber { get; set; }
/// <summary>
/// Gets or sets the value pointing to the file system where the ssl certiifcate is located.
/// </summary>
/// <value>The value pointing to the file system where the ssl certiifcate is located.</value>
public bool UseHttps { get; set; }
/// <summary>
/// Gets or sets the value pointing to the file system where the ssl certiifcate is located..
/// </summary>
/// <value>The value pointing to the file system where the ssl certiifcate is located..</value>
public string CertificatePath { get; set; }
/// <summary> /// <summary>
/// Gets or sets the HTTPS server port number. /// Gets or sets the HTTPS server port number.
/// </summary> /// </summary>

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;

View File

@ -24,7 +24,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ {
public class HttpListenerHost : ServiceStackHost, IHttpServer public class HttpListenerHost : ServiceStackHost, IHttpServer
{ {
private string HandlerPath { get; set; }
private string DefaultRedirectPath { get; set; } private string DefaultRedirectPath { get; set; }
private readonly ILogger _logger; private readonly ILogger _logger;
@ -67,7 +66,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
public HttpListenerHost(IApplicationHost applicationHost, public HttpListenerHost(IApplicationHost applicationHost,
ILogManager logManager, ILogManager logManager,
string serviceName, string serviceName,
string handlerPath,
string defaultRedirectPath, string defaultRedirectPath,
bool supportsNativeWebSocket, bool supportsNativeWebSocket,
params Assembly[] assembliesWithServices) params Assembly[] assembliesWithServices)
@ -75,7 +73,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ {
DefaultRedirectPath = defaultRedirectPath; DefaultRedirectPath = defaultRedirectPath;
_supportsNativeWebSocket = supportsNativeWebSocket; _supportsNativeWebSocket = supportsNativeWebSocket;
HandlerPath = handlerPath;
_logger = logManager.GetLogger("HttpServer"); _logger = logManager.GetLogger("HttpServer");
@ -136,13 +133,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ {
base.OnConfigLoad(); base.OnConfigLoad();
Config.HandlerFactoryPath = string.IsNullOrEmpty(HandlerPath) Config.HandlerFactoryPath = null;
? null
: HandlerPath;
Config.MetadataRedirectPath = string.IsNullOrEmpty(HandlerPath) Config.MetadataRedirectPath = "metadata";
? "metadata"
: PathUtils.CombinePaths(HandlerPath, "metadata");
} }
protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices) protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
@ -314,24 +307,24 @@ namespace MediaBrowser.Server.Implementations.HttpServer
var operationName = httpReq.OperationName; var operationName = httpReq.OperationName;
var localPath = url.LocalPath; var localPath = url.LocalPath;
if (string.Equals(localPath, "/" + HandlerPath + "/", StringComparison.OrdinalIgnoreCase)) if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase))
{ {
httpRes.RedirectToUrl(DefaultRedirectPath); httpRes.RedirectToUrl("/../" + DefaultRedirectPath);
return Task.FromResult(true); return Task.FromResult(true);
} }
if (string.Equals(localPath, "/" + HandlerPath, StringComparison.OrdinalIgnoreCase)) if (string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase))
{ {
httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath); httpRes.RedirectToUrl("../" + DefaultRedirectPath);
return Task.FromResult(true); return Task.FromResult(true);
} }
if (string.Equals(localPath, "/", StringComparison.OrdinalIgnoreCase)) if (string.Equals(localPath, "/", StringComparison.OrdinalIgnoreCase))
{ {
httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath); httpRes.RedirectToUrl(DefaultRedirectPath);
return Task.FromResult(true); return Task.FromResult(true);
} }
if (string.IsNullOrEmpty(localPath)) if (string.IsNullOrEmpty(localPath))
{ {
httpRes.RedirectToUrl("/" + HandlerPath + "/" + DefaultRedirectPath); httpRes.RedirectToUrl("/" + DefaultRedirectPath);
return Task.FromResult(true); return Task.FromResult(true);
} }
@ -386,12 +379,33 @@ namespace MediaBrowser.Server.Implementations.HttpServer
base.Init(); base.Init();
} }
//public override RouteAttribute[] GetRouteAttributes(System.Type requestType) public override RouteAttribute[] GetRouteAttributes(Type requestType)
//{ {
// var routes = base.GetRouteAttributes(requestType); var routes = base.GetRouteAttributes(requestType).ToList();
// routes.Each(x => x.Path = "/api" + x.Path); var clone = routes.ToList();
// return routes;
//} foreach (var route in clone)
{
routes.Add(new RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs)
{
Notes = route.Notes,
Priority = route.Priority,
Summary = route.Summary
});
}
return routes.ToArray();
}
private string NormalizeRoutePath(string path)
{
if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
return "/mediabrowser" + path;
}
return "mediabrowser/" + path;
}
/// <summary> /// <summary>
/// Releases the specified instance. /// Releases the specified instance.

View File

@ -16,20 +16,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <param name="applicationHost">The application host.</param> /// <param name="applicationHost">The application host.</param>
/// <param name="logManager">The log manager.</param> /// <param name="logManager">The log manager.</param>
/// <param name="serverName">Name of the server.</param> /// <param name="serverName">Name of the server.</param>
/// <param name="handlerPath">The handler path.</param>
/// <param name="defaultRedirectpath">The default redirectpath.</param> /// <param name="defaultRedirectpath">The default redirectpath.</param>
/// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param> /// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param>
/// <returns>IHttpServer.</returns> /// <returns>IHttpServer.</returns>
public static IHttpServer CreateServer(IApplicationHost applicationHost, public static IHttpServer CreateServer(IApplicationHost applicationHost,
ILogManager logManager, ILogManager logManager,
string serverName, string serverName,
string handlerPath,
string defaultRedirectpath, string defaultRedirectpath,
bool supportsNativeWebSocket) bool supportsNativeWebSocket)
{ {
LogManager.LogFactory = new ServerLogFactory(logManager); LogManager.LogFactory = new ServerLogFactory(logManager);
return new HttpListenerHost(applicationHost, logManager, serverName, handlerPath, defaultRedirectpath, supportsNativeWebSocket); return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath, supportsNativeWebSocket);
} }
} }
} }

View File

@ -744,7 +744,7 @@ namespace MediaBrowser.Server.Implementations.Library
text.AppendLine("Use your web browser to visit:"); text.AppendLine("Use your web browser to visit:");
text.AppendLine(string.Empty); text.AppendLine(string.Empty);
text.AppendLine(localAddress + "/mediabrowser/web/forgotpasswordpin.html"); text.AppendLine(localAddress + "/web/forgotpasswordpin.html");
text.AppendLine(string.Empty); text.AppendLine(string.Empty);
text.AppendLine("Enter the following pin code:"); text.AppendLine("Enter the following pin code:");
text.AppendLine(string.Empty); text.AppendLine(string.Empty);

View File

@ -46,6 +46,7 @@
"HeaderTV": "TV", "HeaderTV": "TV",
"HeaderAudio": "Audio", "HeaderAudio": "Audio",
"HeaderVideo": "Video", "HeaderVideo": "Video",
"HeaderPaths": "Paths",
"OptionDetectArchiveFilesAsMedia": "Detect archive files as media", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media",
"OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.", "OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.",
"LabelEnterConnectUserName": "User name or email:", "LabelEnterConnectUserName": "User name or email:",
@ -492,6 +493,7 @@
"HeaderSystemPaths": "System Paths", "HeaderSystemPaths": "System Paths",
"LinkCommunity": "Community", "LinkCommunity": "Community",
"LinkGithub": "Github", "LinkGithub": "Github",
"LinkApi": "Api",
"LinkApiDocumentation": "Api Documentation", "LinkApiDocumentation": "Api Documentation",
"LabelFriendlyServerName": "Friendly server name:", "LabelFriendlyServerName": "Friendly server name:",
"LabelFriendlyServerNameHelp": "This name will be used to identify this server. If left blank, the computer name will be used.", "LabelFriendlyServerNameHelp": "This name will be used to identify this server. If left blank, the computer name will be used.",

View File

@ -130,12 +130,12 @@ namespace MediaBrowser.Server.Startup.Common
{ {
var list = new List<string> var list = new List<string>
{ {
"http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/" "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/"
}; };
if (ServerConfigurationManager.Configuration.UseHttps) if (ServerConfigurationManager.Configuration.UseHttps)
{ {
list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/" + WebApplicationName + "/"); list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/");
} }
return list; return list;
@ -472,7 +472,7 @@ namespace MediaBrowser.Server.Startup.Common
_supportsNativeWebSocket = false; _supportsNativeWebSocket = false;
} }
HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", false); HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html", false);
RegisterSingleInstance(HttpServer, false); RegisterSingleInstance(HttpServer, false);
progress.Report(10); progress.Report(10);
@ -810,7 +810,7 @@ namespace MediaBrowser.Server.Startup.Common
{ {
try try
{ {
ServerManager.Start(HttpServerUrlPrefixes, CertificatePath); ServerManager.Start(HttpServerUrlPrefixes, ServerConfigurationManager.Configuration.CertificatePath);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -977,8 +977,6 @@ namespace MediaBrowser.Server.Startup.Common
CachePath = ApplicationPaths.CachePath, CachePath = ApplicationPaths.CachePath,
MacAddress = GetMacAddress(), MacAddress = GetMacAddress(),
HttpServerPortNumber = HttpServerPort, HttpServerPortNumber = HttpServerPort,
UseHttps = UseHttps,
CertificatePath = CertificatePath,
OperatingSystem = OperatingSystemDisplayName, OperatingSystem = OperatingSystemDisplayName,
CanSelfRestart = CanSelfRestart, CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate, CanSelfUpdate = CanSelfUpdate,
@ -1053,16 +1051,6 @@ namespace MediaBrowser.Server.Startup.Common
get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; } get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; }
} }
public bool UseHttps
{
get { return this.ServerConfigurationManager.Configuration.UseHttps; }
}
public string CertificatePath
{
get { return this.ServerConfigurationManager.Configuration.CertificatePath; }
}
public int HttpsServerPort public int HttpsServerPort
{ {
get { return ServerConfigurationManager.Configuration.HttpsPortNumber; } get { return ServerConfigurationManager.Configuration.HttpsPortNumber; }

View File

@ -18,8 +18,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger) public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger)
{ {
var url = "http://localhost:" + appHost.HttpServerPort + "/" + var url = "http://localhost:" + appHost.HttpServerPort + "/web/" + page;
appHost.WebApplicationName + "/web/" + page;
OpenUrl(url, logger); OpenUrl(url, logger);
} }
@ -69,8 +68,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
public static void OpenSwagger(IServerApplicationHost appHost, ILogger logger) public static void OpenSwagger(IServerApplicationHost appHost, ILogger logger)
{ {
OpenUrl("http://localhost:" + appHost.HttpServerPort + "/" + OpenUrl("http://localhost:" + appHost.HttpServerPort + "/swagger-ui/index.html", logger);
appHost.WebApplicationName + "/swagger-ui/index.html", logger);
} }
/// <summary> /// <summary>

View File

@ -25,7 +25,7 @@ namespace MediaBrowser.ServerApplication
Description = "The windows background service for Media Browser Server.", Description = "The windows background service for Media Browser Server.",
// Will ensure the network is available // Will ensure the network is available
ServicesDependedOn = new[] { "LanmanServer" } ServicesDependedOn = new[] { "LanmanServer", "Tcpip" }
}; };
// Microsoft didn't add the ability to add a // Microsoft didn't add the ability to add a