23

Is there a library for implementing service discovery and publishing via UPnP?

(I am trying to find some alternatives to JmDNS that while protocol-wise worked fine for our purposes, was highly unstable as a library, having an unacceptably bad tendency for deadlocking itself.)

Roland Tepp
  • 8,301
  • 11
  • 55
  • 73
  • 1
    You can also try: http://sourceforge.net/projects/cgupnpjava/ – lordhong Jul 13 '10 at 22:34
  • I think we fixed all the deadlocks we ever found in JmDNS, but it has far bigger problems than that, e.g. it doesn't work *at all* on some systems. – Hakanai Mar 12 '14 at 02:35

2 Answers2

26

http://4thline.org/projects/cling/

Open Source DLNA/UPnP stack, libraries, and tools for Java and Android developers

Community
  • 1
  • 1
  • @Roland : Can u just tell me what exactly u r about to do? i need help on discovering the UPnP device in android.. I want to make app which my android device serves as a medium which can be able to stream media from internet and then make available to UPnP device..Any help on this.. – Rakesh Gondaliya Sep 15 '10 at 12:35
  • Thanks i was looking forward for this only...thanks – Rakesh Gondaliya Sep 16 '10 at 12:29
  • We need it for integration with a 3rd party POS system that uses UPnP for comunication and negotiation. I can't really help you out in your particular case (fwiw - I find UPnP to be an extremely ugly protocol) – Roland Tepp Sep 20 '10 at 07:53
  • I have made an app with this library (https://market.android.com/details?id=com.mikebevz.upnp) but the library throws NulPointerException on Android 3.0+ devices. Does anyone see this problem? – Mike Bevz Sep 28 '11 at 11:53
  • The library is no longer maintained so probably not a good choice anymore – SubJunk May 18 '20 at 05:45
9

You could also try ohNet which includes Java bindings and control point / device stacks under a BSD license.

(Disclaimer: I have contributed to this project)

simonc
  • 41,632
  • 12
  • 85
  • 103
  • interesting... but i can not found how can i get my gateway UDN with it. is it possible to do that? – imanis_tn Apr 05 '12 at 21:35
  • 1
    @IMAnis_tn use CpDeviceListUpnpDeviceType("upnp.org", "InternetGatewayDevice", 1, listener). 'listener' will be called back each time such a device is found. Use the getUdn() function to retrieve the device udn. You could also use CpDeviceListUpnpServiceType if you want to search for a particular service type. – simonc Apr 06 '12 at 12:00
  • @IMAnis_tn it'd also be worth having a look at the Control Point overview on the [project wiki](http://www.openhome.org/wiki/OhNet) for details on how to initialise the library – simonc Apr 06 '12 at 17:00
  • 1
    Looks like it is not 100% Java. – Thorbjørn Ravn Andersen Jun 02 '12 at 11:38
  • @ThorbjørnRavnAndersen that's correct. Its a C++ library with Java wrappers for all public APIs. The C++ code can be built for Android, Windows, Mac & Linux so can be trivially deployed to platforms most likely to host Java. Ports to other OSes would be possible too. – simonc Jun 02 '12 at 12:09
  • @simonc, hmm why aren't there some getting-started samples – Pacerier Oct 05 '12 at 14:05
  • @Pacerier the [overview docs](http://www.openhome.org/wiki/OhNet#Overview_docs) cover this – simonc Oct 05 '12 at 14:17