1
0
Fork 0
mirror of https://github.com/airsonic/airsonic.git synced 2025-10-03 09:49:17 +02:00

Restore DLNA support class (reverts part of d6264630)

The classes from org.fourthline.cling.transport.impl.apache are actually
needed to make Cling (the UPnP/DLNA) library work on Apache Tomcat, as
explained in the documentation[0]:

> However, if you are trying to use Cling Core in a runtime container such as Tomcat, JBoss AS, or
> Glassfish, you might run into an error on startup. [...] If your container is already using the
> HTTPURLConnection, you have to switch Cling to an alternative HTTP client. See Configuring network
> transports for other available options and how to change various network-related settings.

[0] http://4thline.org/projects/cling/core/manual/cling-core-manual.xhtml#section.BasicAPI.UpnpService.Configuration
This commit is contained in:
François-Xavier Thomas 2020-04-17 22:33:25 +02:00
parent d3f7947b96
commit ba54226bf4
2 changed files with 53 additions and 2 deletions

View file

@ -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;
@ -122,7 +122,7 @@ public class UPnPService {
}
private synchronized void createService() {
upnpService = new UpnpServiceImpl(new DefaultUpnpServiceConfiguration(SettingsService.getDefaultUPnPPort()));
upnpService = new UpnpServiceImpl(new ApacheUpnpServiceConfiguration());
// Asynch search for other devices (most importantly UPnP-enabled routers for port-mapping)
upnpService.getControlPoint().search();

View file

@ -0,0 +1,51 @@
/*
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()));
}
}