use of org.openhab.core.audio.AudioSink in project openhab-addons by openhab.
the class SqueezeBoxHandlerFactory method removeHandler.
@Override
protected synchronized void removeHandler(ThingHandler thingHandler) {
if (thingHandler instanceof SqueezeBoxServerHandler) {
logger.trace("removing handler for bridge thing {}", thingHandler.getThing());
ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(thingHandler.getThing().getUID());
if (serviceReg != null) {
logger.trace("unregistering player discovery service");
// Get the discovery service object and use it to cancel the RequestPlayerJob
SqueezeBoxPlayerDiscoveryParticipant discoveryService = (SqueezeBoxPlayerDiscoveryParticipant) bundleContext.getService(serviceReg.getReference());
discoveryService.cancelRequestPlayerJob();
// Unregister the PlayerListener from the SqueezeBoxServerHandler
((SqueezeBoxServerHandler) thingHandler).unregisterSqueezeBoxPlayerListener((SqueezeBoxPlayerEventListener) bundleContext.getService(serviceReg.getReference()));
// Unregister the PlayerListener service
serviceReg.unregister();
// Remove the service from the ServiceRegistration map
discoveryServiceRegs.remove(thingHandler.getThing().getUID());
}
}
if (thingHandler instanceof SqueezeBoxPlayerHandler) {
SqueezeBoxServerHandler bridge = ((SqueezeBoxPlayerHandler) thingHandler).getSqueezeBoxServerHandler();
if (bridge != null) {
// Unregister the player's audio sink
logger.trace("Unregistering the audio sync service for player thing {}", thingHandler.getThing().getUID());
ServiceRegistration<AudioSink> reg = audioSinkRegistrations.get(thingHandler.getThing().getUID().toString());
if (reg != null) {
reg.unregister();
}
logger.trace("removing handler for player thing {}", thingHandler.getThing());
bridge.removePlayerCache(((SqueezeBoxPlayerHandler) thingHandler).getMac());
}
}
}
use of org.openhab.core.audio.AudioSink in project openhab-addons by openhab.
the class SqueezeBoxHandlerFactory method createHandler.
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID.equals(SQUEEZEBOXSERVER_THING_TYPE)) {
logger.trace("creating handler for bridge thing {}", thing);
SqueezeBoxServerHandler bridge = new SqueezeBoxServerHandler((Bridge) thing);
registerSqueezeBoxPlayerDiscoveryService(bridge);
return bridge;
}
if (thingTypeUID.equals(SQUEEZEBOXPLAYER_THING_TYPE)) {
logger.trace("creating handler for player thing {}", thing);
SqueezeBoxPlayerHandler playerHandler = new SqueezeBoxPlayerHandler(thing, createCallbackUrl(), stateDescriptionProvider);
// Register the player as an audio sink
logger.trace("Registering an audio sink for player thing {}", thing.getUID());
SqueezeBoxAudioSink audioSink = new SqueezeBoxAudioSink(playerHandler, audioHTTPServer, callbackUrl);
@SuppressWarnings("unchecked") ServiceRegistration<AudioSink> reg = (ServiceRegistration<AudioSink>) bundleContext.registerService(AudioSink.class.getName(), audioSink, new Hashtable<>());
audioSinkRegistrations.put(thing.getUID().toString(), reg);
return playerHandler;
}
return null;
}
use of org.openhab.core.audio.AudioSink in project openhab-addons by openhab.
the class UpnpControlHandlerFactory method registerAudioSink.
@Override
public void registerAudioSink(UpnpRendererHandler handler) {
if (!(callbackUrl.isEmpty())) {
UpnpAudioSink audioSink = new UpnpAudioSink(handler, audioHTTPServer, callbackUrl);
@SuppressWarnings("unchecked") ServiceRegistration<AudioSink> reg = (ServiceRegistration<AudioSink>) bundleContext.registerService(AudioSink.class.getName(), audioSink, new Hashtable<String, Object>());
Thing thing = handler.getThing();
audioSinkRegistrations.put(thing.getUID().toString(), reg);
logger.debug("Audio sink added for media renderer {}", thing.getLabel());
UpnpNotificationAudioSink notificationAudioSink = new UpnpNotificationAudioSink(handler, audioHTTPServer, callbackUrl);
@SuppressWarnings("unchecked") ServiceRegistration<AudioSink> notificationReg = (ServiceRegistration<AudioSink>) bundleContext.registerService(AudioSink.class.getName(), notificationAudioSink, new Hashtable<String, Object>());
audioSinkRegistrations.put(thing.getUID().toString() + NOTIFICATION_AUDIOSINK_EXTENSION, notificationReg);
logger.debug("Notification audio sink added for media renderer {}", thing.getLabel());
}
}
use of org.openhab.core.audio.AudioSink in project openhab-addons by openhab.
the class HeosHandlerFactory method registerAudioSink.
private void registerAudioSink(Thing thing, HeosThingBaseHandler thingBaseHandler) {
HeosAudioSink audioSink = new HeosAudioSink(thingBaseHandler, audioHTTPServer, createCallbackUrl());
@SuppressWarnings("unchecked") ServiceRegistration<AudioSink> reg = (ServiceRegistration<AudioSink>) bundleContext.registerService(AudioSink.class.getName(), audioSink, new Hashtable<>());
audioSinkRegistrations.put(thing.getUID().toString(), reg);
}
use of org.openhab.core.audio.AudioSink in project openhab-addons by openhab.
the class ChromecastHandlerFactory method createHandler.
@Override
@Nullable
protected ThingHandler createHandler(Thing thing) {
ChromecastHandler handler = new ChromecastHandler(thing, audioHTTPServer, createCallbackUrl());
@SuppressWarnings("unchecked") ServiceRegistration<AudioSink> reg = (ServiceRegistration<AudioSink>) bundleContext.registerService(AudioSink.class.getName(), handler, null);
audioSinkRegistrations.put(thing.getUID().toString(), reg);
return handler;
}
Aggregations