refactoring
This commit is contained in:
parent
4ab02bfafe
commit
3a73fa37d6
3 changed files with 5 additions and 50 deletions
|
@ -2,7 +2,6 @@ package net.schowek.nextclouddlna
|
||||||
|
|
||||||
import jakarta.annotation.PreDestroy
|
import jakarta.annotation.PreDestroy
|
||||||
import mu.KLogging
|
import mu.KLogging
|
||||||
import net.schowek.nextclouddlna.dlna.RegistryImplWithOverrides
|
|
||||||
import net.schowek.nextclouddlna.dlna.media.MediaServer
|
import net.schowek.nextclouddlna.dlna.media.MediaServer
|
||||||
import net.schowek.nextclouddlna.dlna.transport.ApacheStreamClient
|
import net.schowek.nextclouddlna.dlna.transport.ApacheStreamClient
|
||||||
import net.schowek.nextclouddlna.dlna.transport.ApacheStreamClientConfiguration
|
import net.schowek.nextclouddlna.dlna.transport.ApacheStreamClientConfiguration
|
||||||
|
@ -10,21 +9,15 @@ import net.schowek.nextclouddlna.dlna.transport.MyStreamServerConfiguration
|
||||||
import net.schowek.nextclouddlna.dlna.transport.MyStreamServerImpl
|
import net.schowek.nextclouddlna.dlna.transport.MyStreamServerImpl
|
||||||
import net.schowek.nextclouddlna.util.ServerInfoProvider
|
import net.schowek.nextclouddlna.util.ServerInfoProvider
|
||||||
import org.jupnp.DefaultUpnpServiceConfiguration
|
import org.jupnp.DefaultUpnpServiceConfiguration
|
||||||
import org.jupnp.UpnpService
|
|
||||||
import org.jupnp.UpnpServiceConfiguration
|
import org.jupnp.UpnpServiceConfiguration
|
||||||
import org.jupnp.UpnpServiceImpl
|
import org.jupnp.UpnpServiceImpl
|
||||||
import org.jupnp.model.message.StreamRequestMessage
|
import org.jupnp.model.message.StreamRequestMessage
|
||||||
import org.jupnp.model.message.StreamResponseMessage
|
import org.jupnp.model.message.StreamResponseMessage
|
||||||
import org.jupnp.model.message.UpnpResponse
|
import org.jupnp.model.message.UpnpResponse
|
||||||
import org.jupnp.model.meta.LocalDevice
|
|
||||||
import org.jupnp.protocol.ProtocolFactory
|
import org.jupnp.protocol.ProtocolFactory
|
||||||
import org.jupnp.protocol.ProtocolFactoryImpl
|
import org.jupnp.registry.RegistryImpl
|
||||||
import org.jupnp.protocol.async.SendingNotificationAlive
|
|
||||||
import org.jupnp.registry.Registry
|
|
||||||
import org.jupnp.transport.impl.NetworkAddressFactoryImpl
|
import org.jupnp.transport.impl.NetworkAddressFactoryImpl
|
||||||
import org.jupnp.transport.spi.NetworkAddressFactory
|
import org.jupnp.transport.spi.NetworkAddressFactory
|
||||||
import org.jupnp.transport.spi.StreamClient
|
|
||||||
import org.jupnp.transport.spi.StreamServer
|
|
||||||
import org.springframework.context.event.ContextRefreshedEvent
|
import org.springframework.context.event.ContextRefreshedEvent
|
||||||
import org.springframework.context.event.EventListener
|
import org.springframework.context.event.EventListener
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
@ -71,8 +64,7 @@ class DlnaService(
|
||||||
inner class MyUpnpService(
|
inner class MyUpnpService(
|
||||||
configuration: UpnpServiceConfiguration
|
configuration: UpnpServiceConfiguration
|
||||||
) : UpnpServiceImpl(configuration) {
|
) : UpnpServiceImpl(configuration) {
|
||||||
override fun createRegistry(pf: ProtocolFactory) =
|
override fun createRegistry(pf: ProtocolFactory) = RegistryImpl(this)
|
||||||
RegistryImplWithOverrides(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class MyUpnpServiceConfiguration : DefaultUpnpServiceConfiguration(serverInfoProvider.port) {
|
private inner class MyUpnpServiceConfiguration : DefaultUpnpServiceConfiguration(serverInfoProvider.port) {
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
package net.schowek.nextclouddlna.dlna
|
|
||||||
|
|
||||||
import mu.KLogging
|
|
||||||
import net.schowek.nextclouddlna.dlna.media.MediaServer
|
|
||||||
import net.schowek.nextclouddlna.dlna.media.MediaServer.Companion.ICON_FILENAME
|
|
||||||
import org.jupnp.UpnpService
|
|
||||||
import org.jupnp.model.resource.IconResource
|
|
||||||
import org.jupnp.model.resource.Resource
|
|
||||||
import org.jupnp.registry.RegistryImpl
|
|
||||||
import org.jupnp.registry.RegistryMaintainer
|
|
||||||
import java.io.IOException
|
|
||||||
import java.net.URI
|
|
||||||
|
|
||||||
|
|
||||||
class RegistryImplWithOverrides(
|
|
||||||
private val upnpService: UpnpService
|
|
||||||
) : RegistryImpl(upnpService) {
|
|
||||||
private var icon: Resource<*>
|
|
||||||
|
|
||||||
init {
|
|
||||||
try {
|
|
||||||
val deviceIcon = MediaServer.createDeviceIcon()
|
|
||||||
icon = IconResource(deviceIcon.uri, deviceIcon)
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
@Throws(IllegalArgumentException::class)
|
|
||||||
override fun getResource(pathQuery: URI): Resource<*>? {
|
|
||||||
return if ("/$ICON_FILENAME" == pathQuery.path) {
|
|
||||||
icon
|
|
||||||
} else super.getResource(pathQuery)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object : KLogging()
|
|
||||||
}
|
|
|
@ -2,9 +2,10 @@ package net.schowek.nextclouddlna.dlna
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
import mu.KLogging
|
import mu.KLogging
|
||||||
import org.jupnp.model.message.*
|
import org.jupnp.model.message.StreamRequestMessage
|
||||||
|
import org.jupnp.model.message.UpnpHeaders
|
||||||
|
import org.jupnp.model.message.UpnpRequest
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
import java.net.InetAddress
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
|
Loading…
Reference in a new issue