Fix DLNA port, and expose them in Docker

Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
This commit is contained in:
Randomnicode
2019-11-23 14:33:13 -07:00
committed by Andrew DeMaria
parent e789e531d0
commit d626463060
5 changed files with 18 additions and 55 deletions
@@ -209,6 +209,8 @@ public class SettingsService {
private static final String DEFAULT_DATABASE_CONFIG_JNDI_NAME = null;
private static final Integer DEFAULT_DATABASE_MYSQL_VARCHAR_MAXLENGTH = 512;
private static final String DEFAULT_DATABASE_USERTABLE_QUOTE = null;
private static final int DEFAULT_UPNP_PORT = 4041;
// Array of obsolete keys. Used to clean property file.
private static final List<String> OBSOLETE_KEYS = Arrays.asList("PortForwardingPublicPort", "PortForwardingLocalPort",
@@ -287,6 +289,10 @@ public class SettingsService {
public static String getDefaultJDBCUrl() {
return "jdbc:hsqldb:file:" + getAirsonicHome().getPath() + "/db/" + getFileSystemAppName();
}
public static int getDefaultUPnpPort() {
return Optional.ofNullable(System.getProperty("UPNP_PORT")).map(x -> Integer.parseInt(x)).orElse(DEFAULT_UPNP_PORT);
}
public static File getLogFile() {
File airsonicHome = SettingsService.getAirsonicHome();
@@ -19,10 +19,10 @@
*/
package org.airsonic.player.service;
import org.airsonic.player.service.upnp.ApacheUpnpServiceConfiguration;
import org.airsonic.player.service.upnp.CustomContentDirectory;
import org.airsonic.player.service.upnp.MSMediaReceiverRegistrarService;
import org.airsonic.player.util.FileUtil;
import org.fourthline.cling.DefaultUpnpServiceConfiguration;
import org.fourthline.cling.UpnpService;
import org.fourthline.cling.UpnpServiceImpl;
import org.fourthline.cling.binding.annotations.AnnotationLocalServiceBinder;
@@ -61,10 +61,13 @@ public class UPnPService {
@Autowired
private SettingsService settingsService;
private UpnpService upnpService;
@Autowired
@Qualifier("dispatchingContentDirectory")
private CustomContentDirectory dispatchingContentDirectory;
private AtomicReference<Boolean> running = new AtomicReference<>(false);
@PostConstruct
@@ -112,14 +115,14 @@ public class UPnPService {
try {
LOG.info("Starting UPnP service...");
createService();
LOG.info("Starting UPnP service - Done!");
LOG.info("Successfully started UPnP service on port {}!", SettingsService.getDefaultUPnpPort());
} catch (Throwable x) {
LOG.error("Failed to start UPnP service: " + x, x);
}
}
private synchronized void createService() {
upnpService = new UpnpServiceImpl(new ApacheUpnpServiceConfiguration());
upnpService = new UpnpServiceImpl(new DefaultUpnpServiceConfiguration(SettingsService.getDefaultUPnpPort()));
// Asynch search for other devices (most importantly UPnP-enabled routers for port-mapping)
upnpService.getControlPoint().search();
@@ -1,51 +0,0 @@
/*
This file is part of Airsonic.
Airsonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Airsonic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Airsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2016 (C) Airsonic Authors
Based upon Subsonic, Copyright 2013 (C) Sindre Mehus
*/
package org.airsonic.player.service.upnp;
import org.fourthline.cling.DefaultUpnpServiceConfiguration;
import org.fourthline.cling.transport.impl.apache.StreamClientConfigurationImpl;
import org.fourthline.cling.transport.impl.apache.StreamClientImpl;
import org.fourthline.cling.transport.impl.apache.StreamServerConfigurationImpl;
import org.fourthline.cling.transport.impl.apache.StreamServerImpl;
import org.fourthline.cling.transport.spi.NetworkAddressFactory;
import org.fourthline.cling.transport.spi.StreamClient;
import org.fourthline.cling.transport.spi.StreamServer;
import java.util.concurrent.Executors;
/**
* UPnP configuration which uses Apache HttpComponents. Needed to make UPnP work
* when deploying on Tomcat.
*
* @author Sindre Mehus
* @version $Id$
*/
public class ApacheUpnpServiceConfiguration extends DefaultUpnpServiceConfiguration {
@Override
public StreamClient createStreamClient() {
return new StreamClientImpl(new StreamClientConfigurationImpl(Executors.newCachedThreadPool()));
}
@Override
public StreamServer createStreamServer(NetworkAddressFactory networkAddressFactory) {
return new StreamServerImpl(new StreamServerConfigurationImpl(networkAddressFactory.getStreamListenPort()));
}
}